mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-18 13:44:12 +00:00
refactor(report): reduce footprint and take writes off the cue path
Cuts the risk surface of the run history feature while keeping what it delivers. Stability: - Sidecar writes were happening on every event stop, and each write serialised the project's entire history. That put work proportional to everything that ever ran onto the show critical path, growing without bound. Writes during a run are now coalesced, with immediate writes for anything a user did and a flush on finish, project change and shutdown. - The editor no longer carries any of this feature's code. The per event last run chip is gone, so RundownEventChip, RundownEventInner and useProjectRundowns are back to their previous state. Each rundown row had gained two extra query subscriptions, one of them polling. - closeRun is no longer called from runtime.service, so the timer path is untouched. Ending a run is now explicit, which also means a mid show stop and restart no longer splits one show across two runs. Discovery: - A run indicator in the editor overview appears only while a run is being recorded. It shows when recording started and carries the Finish action, then links to the report. One component with one subscription, rather than anything per row. Smaller: - report.parser drops from exhaustive validation of a file we write ourselves to a shallow shape check; the failure mode is unchanged. - getCombinedReport returns to its original shape, keeping only the snapshot read that report accuracy depends on. - Removes getLatestRun and GET /runs/latest, which only existed for the chip, and hand rolled refetches the api layer already covers. Production diff is down from ~1460 to ~1290 lines, and the four floating promises the previous revision introduced are gone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019nr3FbLbM8gB8Jm771YgTV
This commit is contained in:
@@ -45,22 +45,11 @@ export async function fetchRun(id: string, options?: RequestOptions): Promise<Sh
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTP request to fetch the most recently closed run, optionally scoped to a rundown
|
||||
* @returns null if there is no closed run yet
|
||||
* HTTP request to close the run in progress, writing it to history immediately
|
||||
*/
|
||||
export async function fetchLatestRun(rundownId?: string, options?: RequestOptions): Promise<ShowRun | null> {
|
||||
try {
|
||||
const res = await axios.get(`${reportUrl}/runs/latest`, {
|
||||
signal: options?.signal,
|
||||
params: rundownId ? { rundownId } : undefined,
|
||||
});
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error) && error.response?.status === 404) {
|
||||
return null;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
export async function finishRun(): Promise<void> {
|
||||
await axios.post(`${reportUrl}/runs/finish`);
|
||||
await ontimeQueryClient.invalidateQueries({ queryKey: REPORT });
|
||||
}
|
||||
|
||||
export async function renameRun(id: string, label: string): Promise<ShowRun> {
|
||||
|
||||
Reference in New Issue
Block a user