records: exclude indoor/treadmill/virtual sub_sport; rebuild athlete.json on bake

- fit.py: map FIT sub_sport 'treadmill' and 'virtual' to 'indoor'
- writer.py: broaden _is_outdoor to catch all indoor sub_sport variants
- render/cli.py: rebuild athlete.json from index.json on every bake so
  records never go stale when the exclusion logic changes
This commit is contained in:
Davide Scaini
2026-05-14 23:37:54 +02:00
parent b509db4940
commit 1ce94b8536
3 changed files with 35 additions and 1 deletions
+2
View File
@@ -147,11 +147,13 @@ def _normalise_sub_sport(value: Any) -> str | None:
mapping = {
"generic": None, # FIT default — unspecified
"virtual_activity": "indoor",
"virtual": "indoor",
"road": "road",
"mountain": "mountain",
"gravel_cycling": "gravel",
"cyclocross": "gravel",
"indoor_cycling": "indoor",
"treadmill": "indoor",
"trail": "trail",
"track": "track",
"cross_country_skiing": "nordic",
+3 -1
View File
@@ -277,8 +277,10 @@ def write_athlete_json(summaries: list[dict], output_dir: Path, athlete_config:
best[d] = w
return [[d, w] for d, w in sorted(best.items())]
_INDOOR_SUB_SPORTS = {"indoor", "treadmill", "virtual"}
def _is_outdoor(s: dict) -> bool:
return s.get("sub_sport") != "indoor"
return s.get("sub_sport") not in _INDOOR_SUB_SPORTS
all_mmps = [s["mmp"] for s in summaries if s.get("mmp") and _is_outdoor(s)]
mmps_365 = [s["mmp"] for s in summaries if s.get("mmp") and _is_outdoor(s) and s["started_at"] >= cutoff_365]