refactor: consolidate toDbMs into query-shared.ts

This commit is contained in:
2026-03-28 12:06:58 -07:00
parent c43941fc7e
commit 5348ae8528
5 changed files with 8 additions and 15 deletions

View File

@@ -1,9 +1,6 @@
import type { DatabaseSync } from './sqlite';
import { nowMs } from './time';
function toDbMs(ms: number | bigint): bigint {
return BigInt(Math.trunc(Number(ms)));
}
import { toDbMs } from './query-shared';
const ROLLUP_STATE_KEY = 'last_rollup_sample_ms';
const DAILY_MS = 86_400_000;

View File

@@ -16,6 +16,7 @@ import {
getAffectedWordIdsForSessions,
getAffectedWordIdsForVideo,
refreshLexicalAggregates,
toDbMs,
} from './query-shared';
type CleanupVocabularyRow = {
@@ -543,6 +544,3 @@ export function deleteVideo(db: DatabaseSync, videoId: number): void {
throw error;
}
}
function toDbMs(ms: number | bigint): bigint {
return BigInt(Math.trunc(Number(ms)));
}

View File

@@ -270,3 +270,7 @@ export function deleteSessionsByIds(db: DatabaseSync, sessionIds: number[]): voi
);
db.prepare(`DELETE FROM imm_sessions WHERE session_id IN (${placeholders})`).run(...sessionIds);
}
export function toDbMs(ms: number | bigint): bigint {
return BigInt(Math.trunc(Number(ms)));
}

View File

@@ -4,10 +4,7 @@ import { createInitialSessionState } from './reducer';
import { nowMs } from './time';
import { SESSION_STATUS_ACTIVE, SESSION_STATUS_ENDED } from './types';
import type { SessionState } from './types';
function toDbMs(ms: number | bigint): bigint {
return BigInt(Math.trunc(Number(ms)));
}
import { toDbMs } from './query-shared';
export function startSessionRecord(
db: DatabaseSync,

View File

@@ -4,10 +4,7 @@ import type { DatabaseSync } from './sqlite';
import { nowMs } from './time';
import { SCHEMA_VERSION } from './types';
import type { QueuedWrite, VideoMetadata, YoutubeVideoMetadata } from './types';
function toDbMs(ms: number | bigint): bigint {
return BigInt(Math.trunc(Number(ms)));
}
import { toDbMs } from './query-shared';
export interface TrackerPreparedStatements {
telemetryInsertStmt: ReturnType<DatabaseSync['prepare']>;