Migration: add detailed logging for device, item, and video probe counts

Reports devices migrated, total playlist items created, videos probed
via ffprobe, and existing schedules. Helps verify the migration ran
correctly on first startup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ScreenTinker 2026-04-11 22:25:42 -05:00
parent 1483500458
commit df7919f84f

View file

@ -151,6 +151,8 @@ async function migrateAssignmentsToPlaylists() {
// Probe durations outside the transaction (async ffprobe can't run inside SQLite transaction) // Probe durations outside the transaction (async ffprobe can't run inside SQLite transaction)
const devicePlaylists = []; const devicePlaylists = [];
let videosProbed = 0;
let totalItems = 0;
for (const device of devicesWithAssignments) { for (const device of devicesWithAssignments) {
const playlistId = uuidv4(); const playlistId = uuidv4();
const assignments = getAssignments.all(device.id); const assignments = getAssignments.all(device.id);
@ -159,9 +161,10 @@ async function migrateAssignmentsToPlaylists() {
let duration = a.duration_sec; let duration = a.duration_sec;
if (a.content_id && a.mime_type?.startsWith('video/')) { if (a.content_id && a.mime_type?.startsWith('video/')) {
const probed = await probeVideoDuration({ id: a.content_id, mime_type: a.mime_type, filepath: a.filepath, duration_sec: a.content_duration }); const probed = await probeVideoDuration({ id: a.content_id, mime_type: a.mime_type, filepath: a.filepath, duration_sec: a.content_duration });
if (probed) duration = probed; if (probed) { duration = probed; videosProbed++; }
} }
items.push({ content_id: a.content_id, widget_id: a.widget_id, sort_order: a.sort_order, duration_sec: duration }); items.push({ content_id: a.content_id, widget_id: a.widget_id, sort_order: a.sort_order, duration_sec: duration });
totalItems++;
} }
devicePlaylists.push({ device, playlistId, items }); devicePlaylists.push({ device, playlistId, items });
} }
@ -182,7 +185,8 @@ async function migrateAssignmentsToPlaylists() {
}); });
migrate(); migrate();
console.log(`Migration complete: ${devicesWithAssignments.length} playlist(s) created.`); const scheduleCount = db.prepare('SELECT COUNT(*) as count FROM schedules').get().count;
console.log(`Migration complete: ${devicesWithAssignments.length} device(s), ${totalItems} playlist item(s), ${videosProbed} video(s) probed, ${scheduleCount} schedule(s).`);
} }
migrateAssignmentsToPlaylists().catch(e => console.error('Migration error:', e)); migrateAssignmentsToPlaylists().catch(e => console.error('Migration error:', e));