feat: add Settings live stream analysis button and diagnose Laya batch failure (#14)
Add a Settings action to manually rerun Live TV stream analysis: it triggers an admin-guarded projection rebuild endpoint that groups streams into logical channels (covering channels present before the projection existed) and reruns language/Laya detection, with progress presented via liveAnalysisPresentation. Harden the Laya batch path that failed with 'Local AI language matching failed' by surfacing the underlying cause and falling back to standard matching cleanly. Guard admin-only rebuild through a new authz helper and cover routes, service and presentation with tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -2,7 +2,8 @@ const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const {
|
||||
projectCatalog,
|
||||
serializeChannels
|
||||
serializeChannels,
|
||||
startRebuild
|
||||
} = require('../server/services/liveProjectionService');
|
||||
const {
|
||||
LIVE_PROJECTION_COLUMNS,
|
||||
@ -30,6 +31,25 @@ test('projection migration declares grouping and language columns', () => {
|
||||
assert.match(LIVE_PROJECTION_SCHEMA_SQL, /idx_items_logical_channel/);
|
||||
});
|
||||
|
||||
test('manual rebuild scheduling coalesces concurrent requests', async () => {
|
||||
let scheduled;
|
||||
let runs = 0;
|
||||
const state = { status: 'building', processed_count: 0, total_count: 2 };
|
||||
const options = {
|
||||
mark: () => state,
|
||||
runner: async () => { runs++; return { status: 'success' }; },
|
||||
schedule: callback => { scheduled = callback; }
|
||||
};
|
||||
const first = startRebuild({}, options);
|
||||
const second = startRebuild({}, options);
|
||||
assert.equal(first.alreadyRunning, false);
|
||||
assert.equal(second.alreadyRunning, true);
|
||||
assert.equal(second.promise, first.promise);
|
||||
scheduled();
|
||||
await first.promise;
|
||||
assert.equal(runs, 1);
|
||||
});
|
||||
|
||||
test('projects beIN quality variants into one logical channel', () => {
|
||||
const groups = projectCatalog([
|
||||
item('uhd', '|FR| BEIN SPORTS 1 UHD'),
|
||||
|
||||
Reference in New Issue
Block a user