perf: year-shard index.json to cut initial load from MBs to ~1 year

merge_all/_merged/index.json is now a shard manifest; activities are
split into index-{year}.json files. The feed loads only the most-recent
year on first paint (~200 activities instead of all of them). Older
years are fetched lazily when the user clicks "Load older activities".

Also strips best_efforts / best_climb_m / source from shard files —
these fields are aggregation inputs only, never read by the feed UI.
This commit is contained in:
Davide Scaini
2026-04-19 22:21:10 +02:00
parent bb253cc2c1
commit cada2bcb03
5 changed files with 230 additions and 33 deletions
+9 -4
View File
@@ -83,10 +83,15 @@ class TestPipeline:
merge_all(data_root / "brut")
for handle in ("dave", "brut"):
merged = json.loads((data_root / handle / "_merged" / "index.json").read_text())
assert len(merged["activities"]) >= 8, (
f"Expected ≥8 merged activities for {handle}"
)
merged_dir = data_root / handle / "_merged"
root = json.loads((merged_dir / "index.json").read_text())
# Root index now has year shards; collect all activities across them
all_acts: list = list(root.get("activities", []))
for shard in root.get("shards", []):
sp = merged_dir / shard["url"]
if sp.exists():
all_acts.extend(json.loads(sp.read_text()).get("activities", []))
assert len(all_acts) >= 8, f"Expected ≥8 merged activities for {handle}"
def test_root_manifest(self, data_root):
from bincio.render.cli import _user_dirs, _write_root_manifest