fix: address hover pause and rollup upsert issues

This commit is contained in:
2026-03-01 02:35:00 -08:00
parent 4b0a2ec486
commit b17e3ea32a
3 changed files with 13 additions and 21 deletions

View File

@@ -97,7 +97,6 @@ function upsertDailyRollupsForGroups(
return;
}
const deleteStmt = db.prepare(`DELETE FROM imm_daily_rollups WHERE rollup_day = ? AND video_id = ?`);
const upsertStmt = db.prepare(`
INSERT INTO imm_daily_rollups (
rollup_day, video_id, total_sessions, total_active_min, total_lines_seen,
@@ -150,7 +149,6 @@ function upsertDailyRollupsForGroups(
`);
for (const { rollupDay, videoId } of groups) {
deleteStmt.run(rollupDay, videoId);
upsertStmt.run(rollupNowMs, rollupNowMs, rollupDay, videoId);
}
}
@@ -164,9 +162,6 @@ function upsertMonthlyRollupsForGroups(
return;
}
const deleteStmt = db.prepare(
`DELETE FROM imm_monthly_rollups WHERE rollup_month = ? AND video_id = ?`,
);
const upsertStmt = db.prepare(`
INSERT INTO imm_monthly_rollups (
rollup_month, video_id, total_sessions, total_active_min, total_lines_seen,
@@ -200,7 +195,6 @@ function upsertMonthlyRollupsForGroups(
`);
for (const { rollupMonth, videoId } of groups) {
deleteStmt.run(rollupMonth, videoId);
upsertStmt.run(rollupNowMs, rollupNowMs, rollupMonth, videoId);
}
}
@@ -279,7 +273,14 @@ export function runRollupMaintenance(db: DatabaseSync, forceRebuild = false): vo
})),
);
upsertDailyRollupsForGroups(db, dailyGroups, rollupNowMs);
upsertMonthlyRollupsForGroups(db, monthlyGroups, rollupNowMs);
setLastRollupSampleMs(db, Number(maxSampleRow.maxSampleMs));
db.exec('BEGIN IMMEDIATE');
try {
upsertDailyRollupsForGroups(db, dailyGroups, rollupNowMs);
upsertMonthlyRollupsForGroups(db, monthlyGroups, rollupNowMs);
setLastRollupSampleMs(db, Number(maxSampleRow.maxSampleMs));
db.exec('COMMIT');
} catch (error) {
db.exec('ROLLBACK');
throw error;
}
}

View File

@@ -93,10 +93,9 @@ test('auto-pause on subtitle hover pauses on enter and resumes on leave when ena
]);
});
test('auto-pause on subtitle hover does not unpause when playback becomes paused on leave', async () => {
test('auto-pause on subtitle hover skips when playback is already paused', async () => {
const ctx = createMouseTestContext();
const mpvCommands: Array<(string | number)[]> = [];
const playbackPausedStates = [false, true];
const handlers = createMouseHandlers(ctx as never, {
modalStateReader: {
@@ -107,7 +106,7 @@ test('auto-pause on subtitle hover does not unpause when playback becomes paused
getCurrentYPercent: () => 10,
persistSubtitlePositionPatch: () => {},
getSubtitleHoverAutoPauseEnabled: () => true,
getPlaybackPaused: async () => playbackPausedStates.shift() ?? true,
getPlaybackPaused: async () => true,
sendMpvCommand: (command) => {
mpvCommands.push(command);
},
@@ -116,7 +115,7 @@ test('auto-pause on subtitle hover does not unpause when playback becomes paused
await handlers.handleMouseEnter();
await handlers.handleMouseLeave();
assert.deepEqual(mpvCommands, [['set_property', 'pause', 'yes']]);
assert.deepEqual(mpvCommands, []);
});
test('auto-pause on subtitle hover is skipped when disabled in config', async () => {

View File

@@ -81,14 +81,6 @@ export function createMouseHandlers(
hoverPauseRequestId += 1;
if (pausedBySubtitleHover) {
pausedBySubtitleHover = false;
try {
const isPaused = await options.getPlaybackPaused();
if (isPaused !== false) {
return;
}
} catch {
return;
}
options.sendMpvCommand(['set_property', 'pause', 'no']);
}
if (yomitanPopupVisible) return;