From fb033e3da2adf5ef29c79783e21dc5742931ac90 Mon Sep 17 00:00:00 2001 From: Davide Scaini Date: Wed, 13 May 2026 21:17:55 +0200 Subject: [PATCH] Search: auto-load all year shards when a query is entered so full history is searched --- site/src/components/ActivityFeed.svelte | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/site/src/components/ActivityFeed.svelte b/site/src/components/ActivityFeed.svelte index 6c06c9e..05e4b6c 100644 --- a/site/src/components/ActivityFeed.svelte +++ b/site/src/components/ActivityFeed.svelte @@ -128,6 +128,28 @@ $: if (sport || datePre || query) shown = PAGE_SIZE; // reset pagination on filter change + // When a search query is active, eagerly load all remaining shards so the + // full history is searched (not just the initially-loaded recent year). + let loadingAllShards = false; + $: if (query.trim() && pendingShards.length > 0 && !loadingAllShards) { + loadingAllShards = true; + (async () => { + while (pendingShards.length > 0) { + const url = pendingShards[0]; + pendingShards = pendingShards.slice(1); + try { + const fresh = await loadShardActivities(url); + const existing = new Map(all.map(a => [a.id, a])); + for (const a of fresh) if (!existing.has(a.id)) existing.set(a.id, a); + all = [...existing.values()].sort((a, b) => + (b.started_at ?? '').localeCompare(a.started_at ?? ''), + ); + } catch { /* ignore — partial results still useful */ } + } + loadingAllShards = false; + })(); + } + $: if (mounted) { const params = new URLSearchParams(window.location.search); if (sport === 'all') params.delete('sport'); else params.set('sport', sport);