fix(stats): subtract lifetime totals incrementally on delete (#196)

This commit is contained in:
2026-08-14 22:13:59 -07:00
committed by GitHub
parent 6fb3d2eb13
commit d963def1a9
20 changed files with 1446 additions and 370 deletions
@@ -715,6 +715,37 @@ test('ensureSchema creates large-history performance indexes', () => {
}
});
test('ensureSchema adds the subtitle event index to current-version databases', () => {
const dbPath = makeDbPath();
const db = new Database(dbPath);
try {
ensureSchema(db);
db.exec('DROP INDEX idx_subtitle_lines_event_id');
ensureSchema(db);
const indexes = db.prepare("PRAGMA index_list('imm_subtitle_lines')").all() as Array<{
name: string;
partial: number;
}>;
const eventIndex = indexes.find(({ name }) => name === 'idx_subtitle_lines_event_id');
assert.ok(eventIndex);
assert.equal(eventIndex.partial, 1);
const columns = db.prepare("PRAGMA index_info('idx_subtitle_lines_event_id')").all() as Array<{
name: string;
}>;
assert.deepEqual(
columns.map(({ name }) => name),
['event_id'],
);
} finally {
db.close();
cleanupDbPath(dbPath);
}
});
test('ensureSchema migrates legacy videos and backfills anime metadata from filenames', () => {
const dbPath = makeDbPath();
const db = new Database(dbPath);