mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-01 18:22:41 -08:00
fix: address hover pause and rollup upsert issues
This commit is contained in:
@@ -97,7 +97,6 @@ function upsertDailyRollupsForGroups(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteStmt = db.prepare(`DELETE FROM imm_daily_rollups WHERE rollup_day = ? AND video_id = ?`);
|
|
||||||
const upsertStmt = db.prepare(`
|
const upsertStmt = db.prepare(`
|
||||||
INSERT INTO imm_daily_rollups (
|
INSERT INTO imm_daily_rollups (
|
||||||
rollup_day, video_id, total_sessions, total_active_min, total_lines_seen,
|
rollup_day, video_id, total_sessions, total_active_min, total_lines_seen,
|
||||||
@@ -150,7 +149,6 @@ function upsertDailyRollupsForGroups(
|
|||||||
`);
|
`);
|
||||||
|
|
||||||
for (const { rollupDay, videoId } of groups) {
|
for (const { rollupDay, videoId } of groups) {
|
||||||
deleteStmt.run(rollupDay, videoId);
|
|
||||||
upsertStmt.run(rollupNowMs, rollupNowMs, rollupDay, videoId);
|
upsertStmt.run(rollupNowMs, rollupNowMs, rollupDay, videoId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,9 +162,6 @@ function upsertMonthlyRollupsForGroups(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const deleteStmt = db.prepare(
|
|
||||||
`DELETE FROM imm_monthly_rollups WHERE rollup_month = ? AND video_id = ?`,
|
|
||||||
);
|
|
||||||
const upsertStmt = db.prepare(`
|
const upsertStmt = db.prepare(`
|
||||||
INSERT INTO imm_monthly_rollups (
|
INSERT INTO imm_monthly_rollups (
|
||||||
rollup_month, video_id, total_sessions, total_active_min, total_lines_seen,
|
rollup_month, video_id, total_sessions, total_active_min, total_lines_seen,
|
||||||
@@ -200,7 +195,6 @@ function upsertMonthlyRollupsForGroups(
|
|||||||
`);
|
`);
|
||||||
|
|
||||||
for (const { rollupMonth, videoId } of groups) {
|
for (const { rollupMonth, videoId } of groups) {
|
||||||
deleteStmt.run(rollupMonth, videoId);
|
|
||||||
upsertStmt.run(rollupNowMs, rollupNowMs, rollupMonth, videoId);
|
upsertStmt.run(rollupNowMs, rollupNowMs, rollupMonth, videoId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,7 +273,14 @@ export function runRollupMaintenance(db: DatabaseSync, forceRebuild = false): vo
|
|||||||
})),
|
})),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
db.exec('BEGIN IMMEDIATE');
|
||||||
|
try {
|
||||||
upsertDailyRollupsForGroups(db, dailyGroups, rollupNowMs);
|
upsertDailyRollupsForGroups(db, dailyGroups, rollupNowMs);
|
||||||
upsertMonthlyRollupsForGroups(db, monthlyGroups, rollupNowMs);
|
upsertMonthlyRollupsForGroups(db, monthlyGroups, rollupNowMs);
|
||||||
setLastRollupSampleMs(db, Number(maxSampleRow.maxSampleMs));
|
setLastRollupSampleMs(db, Number(maxSampleRow.maxSampleMs));
|
||||||
|
db.exec('COMMIT');
|
||||||
|
} catch (error) {
|
||||||
|
db.exec('ROLLBACK');
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 ctx = createMouseTestContext();
|
||||||
const mpvCommands: Array<(string | number)[]> = [];
|
const mpvCommands: Array<(string | number)[]> = [];
|
||||||
const playbackPausedStates = [false, true];
|
|
||||||
|
|
||||||
const handlers = createMouseHandlers(ctx as never, {
|
const handlers = createMouseHandlers(ctx as never, {
|
||||||
modalStateReader: {
|
modalStateReader: {
|
||||||
@@ -107,7 +106,7 @@ test('auto-pause on subtitle hover does not unpause when playback becomes paused
|
|||||||
getCurrentYPercent: () => 10,
|
getCurrentYPercent: () => 10,
|
||||||
persistSubtitlePositionPatch: () => {},
|
persistSubtitlePositionPatch: () => {},
|
||||||
getSubtitleHoverAutoPauseEnabled: () => true,
|
getSubtitleHoverAutoPauseEnabled: () => true,
|
||||||
getPlaybackPaused: async () => playbackPausedStates.shift() ?? true,
|
getPlaybackPaused: async () => true,
|
||||||
sendMpvCommand: (command) => {
|
sendMpvCommand: (command) => {
|
||||||
mpvCommands.push(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.handleMouseEnter();
|
||||||
await handlers.handleMouseLeave();
|
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 () => {
|
test('auto-pause on subtitle hover is skipped when disabled in config', async () => {
|
||||||
|
|||||||
@@ -81,14 +81,6 @@ export function createMouseHandlers(
|
|||||||
hoverPauseRequestId += 1;
|
hoverPauseRequestId += 1;
|
||||||
if (pausedBySubtitleHover) {
|
if (pausedBySubtitleHover) {
|
||||||
pausedBySubtitleHover = false;
|
pausedBySubtitleHover = false;
|
||||||
try {
|
|
||||||
const isPaused = await options.getPlaybackPaused();
|
|
||||||
if (isPaused !== false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
options.sendMpvCommand(['set_property', 'pause', 'no']);
|
options.sendMpvCommand(['set_property', 'pause', 'no']);
|
||||||
}
|
}
|
||||||
if (yomitanPopupVisible) return;
|
if (yomitanPopupVisible) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user