fix(badges): reports page fetches all badges on load instead of IDB-only
Reports were IDB-read-only — no data appeared until the badge search page had already populated the cache. Added a background search__event_badge call (limit 5000, try_cache=false) so navigating directly to /reports always gets a fresh full dataset; liveQuery updates reactively. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,9 +9,10 @@ let { data, log_lvl = 0 }: Props = $props();
|
||||
import { liveQuery } from 'dexie';
|
||||
import { page } from '$app/state';
|
||||
|
||||
import { ae_loc } from '$lib/stores/ae_stores';
|
||||
import { ae_loc, ae_api } from '$lib/stores/ae_stores';
|
||||
import { db_events } from '$lib/ae_events/db_events';
|
||||
import { events_loc } from '$lib/stores/ae_events_stores';
|
||||
import { events_func } from '$lib/ae_events/ae_events_functions';
|
||||
|
||||
import { ArrowLeft, TrendingUp, Type, Gauge, LoaderCircle } from '@lucide/svelte';
|
||||
import Reports_badge_long_names from './reports_badge_long_names.svelte';
|
||||
@@ -19,6 +20,20 @@ import Reports_badge_print_throughput from './reports_badge_print_throughput.sve
|
||||
|
||||
let event_id = $derived(page.params.event_id);
|
||||
|
||||
// Reports read from IDB, so we need to ensure IDB is populated even when
|
||||
// arriving directly (without having visited the badge search page first).
|
||||
// Fire a background refresh — liveQuery below will reactively pick up new data.
|
||||
$effect(() => {
|
||||
const eid = event_id;
|
||||
if (!eid || !$ae_api?.api_key) return;
|
||||
events_func.search__event_badge({
|
||||
api_cfg: $ae_api,
|
||||
event_id: eid,
|
||||
limit: 5000,
|
||||
try_cache: false
|
||||
});
|
||||
});
|
||||
|
||||
type ReportKey = 'long_names' | 'print_throughput';
|
||||
let active_report: ReportKey | null = $state(null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user