Skip to content

Commit f276e09

Browse files
committed
fix: frontend glitch on 0-indexed books
1 parent dc696c5 commit f276e09

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

backend/internal/bgloader/loader.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,16 +477,17 @@ func (bl *BackgroundLoader) loadModeInternalCancel(mode stakergs.ModeConfig, can
477477
}
478478
}
479479

480-
lineNum++
481480
line := scanner.Bytes()
482481
if len(line) == 0 {
482+
lineNum++
483483
continue
484484
}
485485

486-
// Copy event data
486+
// Copy event data (0-indexed to match CSV sim_id offset handling)
487487
eventCopy := make(json.RawMessage, len(line))
488488
copy(eventCopy, line)
489489
events[lineNum] = eventCopy
490+
lineNum++
490491

491492
// Send progress update
492493
if lineNum%bl.progressInterval == 0 || time.Since(lastProgressUpdate) > 500*time.Millisecond {

frontend/src/lib/components/DistributionTable.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
3030
// Sort buckets by range_end descending (biggest first)
3131
let sortedBuckets = $derived(() => {
32+
if (!buckets || buckets.length === 0) return [];
3233
return [...buckets].sort((a, b) => b.range_end - a.range_end);
3334
});
3435
@@ -230,6 +231,7 @@
230231
231232
// Calculate total unique payouts from buckets
232233
let totalPayouts = $derived(() => {
234+
if (!buckets) return 0;
233235
return buckets.reduce((sum, b) => sum + b.count, 0);
234236
});
235237
</script>
@@ -256,7 +258,7 @@
256258
{/if}
257259
</div>
258260

259-
{#if buckets.length === 0}
261+
{#if !buckets || buckets.length === 0}
260262
<div class="py-8 text-center text-slate-500">No data</div>
261263
{:else}
262264
<div class="space-y-2">

0 commit comments

Comments
 (0)