mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-01 18:12:06 -07:00
Use shared local-day helpers in immersion tracker tests
- derive midnight and week-boundary timestamps from query-shared utilities - keep split-module coverage aligned with db-local time handling
This commit is contained in:
@@ -50,6 +50,7 @@ import {
|
||||
updateAnimeAnilistInfo,
|
||||
upsertCoverArt,
|
||||
} from '../query-maintenance.js';
|
||||
import { getLocalEpochDay } from '../query-shared.js';
|
||||
import { EVENT_CARD_MINED, EVENT_SUBTITLE_LINE, SOURCE_TYPE_LOCAL } from '../types.js';
|
||||
|
||||
function makeDbPath(): string {
|
||||
@@ -360,9 +361,6 @@ test('split library helpers return anime/media session and analytics rows', () =
|
||||
|
||||
try {
|
||||
const now = new Date();
|
||||
const todayLocalDay = Math.floor(
|
||||
new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime() / 86_400_000,
|
||||
);
|
||||
const animeId = getOrCreateAnimeRecord(db, {
|
||||
parsedTitle: 'Library Anime',
|
||||
canonicalTitle: 'Library Anime',
|
||||
@@ -398,6 +396,7 @@ test('split library helpers return anime/media session and analytics rows', () =
|
||||
0,
|
||||
).getTime();
|
||||
const sessionId = startSessionRecord(db, videoId, startedAtMs).sessionId;
|
||||
const todayLocalDay = getLocalEpochDay(db, startedAtMs);
|
||||
finalizeSessionMetrics(db, sessionId, startedAtMs, {
|
||||
endedAtMs: startedAtMs + 55_000,
|
||||
totalWatchedMs: 55_000,
|
||||
|
||||
@@ -37,6 +37,11 @@ import {
|
||||
getWordOccurrences,
|
||||
upsertCoverArt,
|
||||
} from '../query.js';
|
||||
import {
|
||||
getShiftedLocalDaySec,
|
||||
getStartOfLocalDayTimestamp,
|
||||
toDbTimestamp,
|
||||
} from '../query-shared.js';
|
||||
import {
|
||||
SOURCE_TYPE_LOCAL,
|
||||
SOURCE_TYPE_REMOTE,
|
||||
@@ -44,7 +49,6 @@ import {
|
||||
EVENT_SUBTITLE_LINE,
|
||||
EVENT_YOMITAN_LOOKUP,
|
||||
} from '../types.js';
|
||||
import { toDbTimestamp } from '../query-shared.js';
|
||||
|
||||
function makeDbPath(): string {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'subminer-imm-query-test-'));
|
||||
@@ -728,8 +732,9 @@ test('getTrendsDashboard keeps local-midnight session buckets separate', () => {
|
||||
parseMetadataJson: null,
|
||||
});
|
||||
|
||||
const beforeMidnight = '1772436600000';
|
||||
const afterMidnight = '1772440200000';
|
||||
const boundaryMs = BigInt(getStartOfLocalDayTimestamp(db, '1772436600000'));
|
||||
const beforeMidnight = (boundaryMs - 1n).toString();
|
||||
const afterMidnight = (boundaryMs + 1n).toString();
|
||||
const firstSessionId = 1;
|
||||
const secondSessionId = 2;
|
||||
const insertSession = db.prepare(
|
||||
@@ -1135,8 +1140,9 @@ test('getQueryHints computes weekly new-word cutoff from calendar midnights', ()
|
||||
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
`,
|
||||
);
|
||||
const justBeforeWeekBoundary = 1_772_955_000;
|
||||
const justAfterWeekBoundary = 1_772_958_600;
|
||||
const weekBoundarySec = getShiftedLocalDaySec(db, '1773601200000', -7);
|
||||
const justBeforeWeekBoundary = weekBoundarySec - 1;
|
||||
const justAfterWeekBoundary = weekBoundarySec + 1;
|
||||
insertWord.run(
|
||||
'境界前',
|
||||
'境界前',
|
||||
|
||||
Reference in New Issue
Block a user