feat(history): update the open view live

This commit is contained in:
Sucukdeluxe
2026-08-21 00:48:42 +02:00
parent 18fa58002c
commit 3a95136ef1
10 changed files with 176 additions and 19 deletions
@@ -50,6 +50,19 @@ export interface HistoryPage {
export const HISTORY_PAGE_SIZE = 100;
export function mergeLiveHistoryEntry(
entries: readonly HistoryEntry[],
incoming: HistoryEntry,
limits: { maxEntries: number; maxAgeDays: number },
nowMs: number = Date.now()
): HistoryEntry[] {
const maxEntries = limits.maxEntries > 0 ? Math.min(limits.maxEntries, 100_000) : 500;
const cutoff = limits.maxAgeDays > 0 ? nowMs - limits.maxAgeDays * 86_400_000 : 0;
const merged = [incoming, ...entries.filter((entry) => entry.id !== incoming.id)];
const retained = cutoff > 0 ? merged.filter((entry) => entry.completedAt >= cutoff) : merged;
return retained.length > maxEntries ? retained.slice(0, maxEntries) : retained;
}
export const HISTORY_TABLE_COLUMN_IDS = ["name", "status", "size", "hoster", "started", "completed"] as const;
export type HistoryTableColumnId = typeof HISTORY_TABLE_COLUMN_IDS[number];
export type HistoryTableColumnWidths = Record<HistoryTableColumnId, number>;