mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-30 06:12:06 -07:00
refactor: consolidate toDbMs into query-shared.ts
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
import type { DatabaseSync } from './sqlite';
|
import type { DatabaseSync } from './sqlite';
|
||||||
import { nowMs } from './time';
|
import { nowMs } from './time';
|
||||||
|
import { toDbMs } from './query-shared';
|
||||||
function toDbMs(ms: number | bigint): bigint {
|
|
||||||
return BigInt(Math.trunc(Number(ms)));
|
|
||||||
}
|
|
||||||
|
|
||||||
const ROLLUP_STATE_KEY = 'last_rollup_sample_ms';
|
const ROLLUP_STATE_KEY = 'last_rollup_sample_ms';
|
||||||
const DAILY_MS = 86_400_000;
|
const DAILY_MS = 86_400_000;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
getAffectedWordIdsForSessions,
|
getAffectedWordIdsForSessions,
|
||||||
getAffectedWordIdsForVideo,
|
getAffectedWordIdsForVideo,
|
||||||
refreshLexicalAggregates,
|
refreshLexicalAggregates,
|
||||||
|
toDbMs,
|
||||||
} from './query-shared';
|
} from './query-shared';
|
||||||
|
|
||||||
type CleanupVocabularyRow = {
|
type CleanupVocabularyRow = {
|
||||||
@@ -543,6 +544,3 @@ export function deleteVideo(db: DatabaseSync, videoId: number): void {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function toDbMs(ms: number | bigint): bigint {
|
|
||||||
return BigInt(Math.trunc(Number(ms)));
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -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);
|
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)));
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ import { createInitialSessionState } from './reducer';
|
|||||||
import { nowMs } from './time';
|
import { nowMs } from './time';
|
||||||
import { SESSION_STATUS_ACTIVE, SESSION_STATUS_ENDED } from './types';
|
import { SESSION_STATUS_ACTIVE, SESSION_STATUS_ENDED } from './types';
|
||||||
import type { SessionState } from './types';
|
import type { SessionState } from './types';
|
||||||
|
import { toDbMs } from './query-shared';
|
||||||
function toDbMs(ms: number | bigint): bigint {
|
|
||||||
return BigInt(Math.trunc(Number(ms)));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function startSessionRecord(
|
export function startSessionRecord(
|
||||||
db: DatabaseSync,
|
db: DatabaseSync,
|
||||||
|
|||||||
@@ -4,10 +4,7 @@ import type { DatabaseSync } from './sqlite';
|
|||||||
import { nowMs } from './time';
|
import { nowMs } from './time';
|
||||||
import { SCHEMA_VERSION } from './types';
|
import { SCHEMA_VERSION } from './types';
|
||||||
import type { QueuedWrite, VideoMetadata, YoutubeVideoMetadata } from './types';
|
import type { QueuedWrite, VideoMetadata, YoutubeVideoMetadata } from './types';
|
||||||
|
import { toDbMs } from './query-shared';
|
||||||
function toDbMs(ms: number | bigint): bigint {
|
|
||||||
return BigInt(Math.trunc(Number(ms)));
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TrackerPreparedStatements {
|
export interface TrackerPreparedStatements {
|
||||||
telemetryInsertStmt: ReturnType<DatabaseSync['prepare']>;
|
telemetryInsertStmt: ReturnType<DatabaseSync['prepare']>;
|
||||||
|
|||||||
Reference in New Issue
Block a user