mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-14 14:03:47 -06:00
fix: type the goatcounter totals for mypy
4ac3f7de7 read .get on _get_json's dict | list answer, four errors past mypy-baseline.txt.
This commit is contained in:
1 parent
fcfa29a870
commit
e1795d584e
1 file changed
+4
-3
@@ -41,6 +41,7 @@ import urllib.request
|
||||
from collections import defaultdict
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any, cast
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from common import github_token, load_database, load_emulator_profiles, run_cli
|
||||
@@ -123,7 +124,7 @@ def fetch_queries(start: dt.date, end: dt.date) -> list[Query]:
|
||||
return rows
|
||||
|
||||
|
||||
def fetch_goatcounter(start: dt.date, end: dt.date) -> dict[str, list[tuple[str, int]]]:
|
||||
def fetch_goatcounter(start: dt.date, end: dt.date) -> dict[str, Any]:
|
||||
"""Paths and events with their visit counts, and the referring domains."""
|
||||
token = (CONFIG / "goatcounter-api-token.txt").read_text(encoding="utf-8").strip()
|
||||
auth = {"Authorization": f"Bearer {token}"}
|
||||
@@ -138,8 +139,8 @@ def fetch_goatcounter(start: dt.date, end: dt.date) -> dict[str, list[tuple[str,
|
||||
exclude.append(str(hit["path_id"]))
|
||||
if not answer.get("more"):
|
||||
break
|
||||
refs = _get_json(f"{GOATCOUNTER}/stats/toprefs?{urllib.parse.urlencode({**span, 'limit': 50})}", auth)
|
||||
total = _get_json(f"{GOATCOUNTER}/stats/total?{urllib.parse.urlencode(span)}", auth)
|
||||
refs = cast(dict, _get_json(f"{GOATCOUNTER}/stats/toprefs?{urllib.parse.urlencode({**span, 'limit': 50})}", auth))
|
||||
total = cast(dict, _get_json(f"{GOATCOUNTER}/stats/total?{urllib.parse.urlencode(span)}", auth))
|
||||
# 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))
|
||||
|
||||
Reference in new issue
Block a user