Release 0.6.0

This commit is contained in:
hnzio committed 2026-10-25 09:45:31 +01:00
1 parent fd47910d09
commit b80dded55d
40 files changed
+4080 -856

No files matched your search

+18 -16
View File
@@ -197,10 +197,7 @@ function showTimerRunning(database: Database.Database, showId: string) {
);
}
function elapsedRuns(
runs: { started_at_utc: string; ended_at_utc: string | null }[],
now: string
) {
function elapsedRuns(runs: { started_at_utc: string; ended_at_utc: string | null }[], now: string) {
return runs.reduce(
(total, run) =>
total +
@@ -236,9 +233,7 @@ function resumeSectionTimerRun(database: Database.Database, showId: string, now:
.get(showId) as { id: string } | undefined;
if (!timer) return;
const running = database
.prepare(
'SELECT 1 FROM live_section_timer_runs WHERE timer_id = ? AND ended_at_utc IS NULL'
)
.prepare('SELECT 1 FROM live_section_timer_runs WHERE timer_id = ? AND ended_at_utc IS NULL')
.get(timer.id);
if (!running) {
database
@@ -335,6 +330,9 @@ function executeCommand(
const show = database.prepare('SELECT status FROM shows WHERE id = ?').get(showId) as {
status: string;
};
if (database.prepare('SELECT 1 FROM show_finalizations WHERE show_id = ?').get(showId)) {
throw new Error('SHOW_COMPLETED');
}
if (show.status === 'completed' && !allowCompleted) throw new Error('SHOW_COMPLETED');
if (state.revision !== expectedRevision) throw new Error('CONFLICT');
operation(database, state, now);
@@ -643,9 +641,7 @@ export function resetSectionTimer(
`SELECT section_id, planned_duration_seconds
FROM live_section_timers WHERE show_id = ? AND ended_at_utc IS NULL`
)
.get(showId) as
| { section_id: string; planned_duration_seconds: number }
| undefined;
.get(showId) as { section_id: string; planned_duration_seconds: number } | undefined;
if (!timer) throw new Error('NO_SECTION_TIMER');
const running = showTimerRunning(database, showId);
closeSectionTimer(database, showId, now);
@@ -741,12 +737,10 @@ export function endLive(
)
.run(now, showId);
database
.prepare(
`UPDATE show_live_states SET ended_at_utc = ? WHERE show_id = ?`
)
.prepare(`UPDATE show_live_states SET ended_at_utc = ? WHERE show_id = ?`)
.run(now, showId);
database
.prepare(`UPDATE shows SET status = 'completed', revision = revision + 1, updated_at_utc = ? WHERE id = ?`)
.prepare(`UPDATE shows SET revision = revision + 1, updated_at_utc = ? WHERE id = ?`)
.run(now, showId);
},
nowValue
@@ -766,7 +760,11 @@ export function resumeEndedLive(
'resume-ended',
(database, state, now) => {
if (!state.ended_at_utc) throw new Error('NOT_ENDED');
database.prepare(`UPDATE shows SET status = 'live', revision = revision + 1, updated_at_utc = ? WHERE id = ?`).run(now, showId);
database
.prepare(
`UPDATE shows SET status = 'live', revision = revision + 1, updated_at_utc = ? WHERE id = ?`
)
.run(now, showId);
database
.prepare('UPDATE show_live_states SET ended_at_utc = NULL WHERE show_id = ?')
.run(showId);
@@ -815,7 +813,11 @@ export function startNewLiveRun(
WHERE show_id = ?`
)
.run(now, showId);
database.prepare(`UPDATE shows SET status = 'live', revision = revision + 1, updated_at_utc = ? WHERE id = ?`).run(now, showId);
database
.prepare(
`UPDATE shows SET status = 'live', revision = revision + 1, updated_at_utc = ? WHERE id = ?`
)
.run(now, showId);
openShowTimerRun(database, showId, now);
const target = orderedUsages(database, showId).find((usage) => usage.status === 'open');
if (target) activateUsage(database, showId, target.id, now);