From 801140ac511d65782e1c37e804400def7fe8a3f8 Mon Sep 17 00:00:00 2001 From: Davide Scaini Date: Sun, 24 May 2026 13:06:37 +0200 Subject: [PATCH] feat: show accumulated distance per gear item in gear tab Compute total distance from allActivities where gear name matches and display it inline next to each gear item. Also add gear field to ActivitySummary type so index shard gear data is accessible in the UI. --- site/src/components/AthleteView.svelte | 10 ++++++++++ site/src/lib/types.ts | 1 + 2 files changed, 11 insertions(+) diff --git a/site/src/components/AthleteView.svelte b/site/src/components/AthleteView.svelte index 743a198..538b8b5 100644 --- a/site/src/components/AthleteView.svelte +++ b/site/src/components/AthleteView.svelte @@ -151,6 +151,13 @@ $: if (activeTab === 'gear' && isOwner && !gearFetched && !gearLoading) gearFetch(); + $: gearDistances = Object.fromEntries( + gearItems.map(g => [ + g.name, + allActivities.filter(a => a.gear === g.name).reduce((sum, a) => sum + (a.distance_m ?? 0), 0), + ]) + ); + $: if (activeTab === 'segments' && segmentsHandle && !segmentsFetched && !segmentsLoading) { segmentsLoading = true; segmentsFetched = true; @@ -483,6 +490,9 @@
{GEAR_ICONS[item.type] ?? '⚙️'} {item.name} + {#if gearDistances[item.name] > 0} + {formatDistance(gearDistances[item.name])} + {/if} {#if item.retired} Retired {/if} diff --git a/site/src/lib/types.ts b/site/src/lib/types.ts index 2dc1c32..62ec87e 100644 --- a/site/src/lib/types.ts +++ b/site/src/lib/types.ts @@ -69,6 +69,7 @@ export interface ActivitySummary { climbing_vam_mh?: number | null; climbing_time_s?: number | null; source: string | null; + gear: string | null; privacy: Privacy; detail_url: string | null; track_url: string | null;