mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-12 21:13:49 -06:00
fix: count clicks apart from direct visits
GoatCounter files an action as a direct visit: the report subtracts them and states page views and actions apart.
This commit is contained in:
1 parent
e7c4de27bc
commit
4ac3f7de71
1 file changed
+10
-3
@@ -139,8 +139,14 @@ def fetch_goatcounter(start: dt.date, end: dt.date) -> dict[str, list[tuple[str,
|
|||||||
if not answer.get("more"):
|
if not answer.get("more"):
|
||||||
break
|
break
|
||||||
refs = _get_json(f"{GOATCOUNTER}/stats/toprefs?{urllib.parse.urlencode({**span, 'limit': 50})}", auth)
|
refs = _get_json(f"{GOATCOUNTER}/stats/toprefs?{urllib.parse.urlencode({**span, 'limit': 50})}", auth)
|
||||||
referrers = [(r.get("name") or "(direct)", int(r["count"])) for r in refs.get("stats", [])]
|
total = _get_json(f"{GOATCOUNTER}/stats/total?{urllib.parse.urlencode(span)}", auth)
|
||||||
return {"hits": hits, "referrers": referrers}
|
# An action carries no referrer, and GoatCounter files it as a direct
|
||||||
|
# visit: 592 of the first day's 1,145 "direct" were clicks.
|
||||||
|
events = int(total.get("total_events", 0))
|
||||||
|
referrers = [("(direct)", max(int(r["count"]) - events, 0)) if not r.get("name") else (r["name"], int(r["count"]))
|
||||||
|
for r in refs.get("stats", [])]
|
||||||
|
return {"hits": hits, "referrers": sorted(referrers, key=lambda row: -row[1]),
|
||||||
|
"visits": int(total.get("total", 0)) - events, "actions": events}
|
||||||
|
|
||||||
|
|
||||||
def fetch_github() -> dict:
|
def fetch_github() -> dict:
|
||||||
@@ -246,7 +252,8 @@ def report(start: dt.date, end: dt.date, queries: list[Query] | None, goat: dict
|
|||||||
"helpful": "Did this page help?", "get": "Pack pages opened",
|
"helpful": "Did this page help?", "get": "Pack pages opened",
|
||||||
"download": "Release downloads", "file": "File downloads", "copy": "Copy buttons",
|
"download": "Release downloads", "file": "File downloads", "copy": "Copy buttons",
|
||||||
"out": "Links leaving the site", "pages": "Pages"}
|
"out": "Links leaving the site", "pages": "Pages"}
|
||||||
out += ["## On the site", ""]
|
out += ["## On the site", "",
|
||||||
|
f"{goat.get('visits', 0):,} page views, {goat.get('actions', 0):,} actions.", ""]
|
||||||
for kind, title in named.items():
|
for kind, title in named.items():
|
||||||
if kind in actions:
|
if kind in actions:
|
||||||
out += [f"### {title}", "", *_table(("Name", "Visits"), [(n, f"{c:,}") for n, c in actions[kind]])]
|
out += [f"### {title}", "", *_table(("Name", "Visits"), [(n, f"{c:,}") for n, c in actions[kind]])]
|
||||||
|
|||||||
Reference in new issue
Block a user