Add resumable bulk lyrics operations

This commit is contained in:
Jonathan Sykes
2026-10-14 02:36:30 +08:00
parent 555027a61c
commit 703aef617b
25 changed files with 547 additions and 55 deletions

View File

@@ -285,6 +285,25 @@ test('admin song list includes metadata-only phone songs for lyrics lookup', asy
expect((await app.request('/api/admin/media/phoneSong01/redownload', { method: 'POST' })).status).toBe(401);
});
test('Whisper enqueue reports a full queue without depending on request context', async () => {
await dbmod.upsertMedia(VID, { status: 'ready', duration: 60 });
const activeIds = Array.from({ length: 25 }, (_, index) => `QF${String(index).padStart(9, '0')}`);
const now = Math.floor(Date.now() / 1000);
await dbmod.db.execute({
sql: `INSERT INTO lyric_transcriptions(id,video_id,status,base_rev,created_at,updated_at) VALUES ${activeIds.map(() => '(?,? ,\'queued\',0,?,?)').join(',')}`,
args: activeIds.flatMap((id, index) => [String(index), id, now, now]),
});
try {
const cookie = await adminCookie();
const response = await app.request(`/api/admin/transcriptions/${VID}`, json('POST', {}, { Cookie: cookie }));
expect(response.status).toBe(429);
expect(await response.json()).toMatchObject({ ok: false, error: 'The transcription queue is full. Try again after a job finishes.' });
} finally {
await dbmod.db.execute({ sql: `DELETE FROM lyric_transcriptions WHERE video_id IN (${activeIds.map(() => '?').join(',')})`, args: activeIds });
await dbmod.deleteMedia(VID);
}
});
test('report triage filters aging flags and resolves every open report for one song', async () => {
const id = VID;
const a = await dbmod.upsertFlag({ videoId: id, index: 0, text: 'Flagged line', rev: 1, reason: 'words', note: '', reporter: 'listener-a' });