B5: UPS chart re-sorts already-sorted data #5

Open
opened 2026-06-05 10:21:45 +00:00 by sebse · 0 comments
Owner

Bug

File: web/components/ChartCard/UpsChart.tsx:35-40

API returns UPS data with ORDER BY real_time ASC — guaranteed sorted. The component sorts again unconditionally.

Impact

Wasted O(n log n) per chart render for no reason.

Code reference

const sorted = [...upsRows].sort((a, b) =>
  timeMode === tick
    ? a.game_tick - b.game_tick
    : new Date(a.real_time).getTime() - new Date(b.real_time).getTime()
);

Fix

Remove the sort. API already guarantees ORDER BY real_time ASC. If tick-mode sorting differs, handle at query level instead.

## Bug **File:** `web/components/ChartCard/UpsChart.tsx:35-40` API returns UPS data with `ORDER BY real_time ASC` — guaranteed sorted. The component sorts again unconditionally. ### Impact Wasted O(n log n) per chart render for no reason. ### Code reference ```tsx const sorted = [...upsRows].sort((a, b) => timeMode === tick ? a.game_tick - b.game_tick : new Date(a.real_time).getTime() - new Date(b.real_time).getTime() ); ``` ### Fix Remove the sort. API already guarantees `ORDER BY real_time ASC`. If tick-mode sorting differs, handle at query level instead.
sebse added the bug label 2026-06-05 10:21:45 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sebse/factorio-signal-exporter#5