Fix immersion tracker SQLite timestamp truncation

- Bind epoch ms values as text to avoid libsql numeric truncation
- Update retention, lifetime, and query tests for string timestamps
- Add backlog ticket for the SQLite timestamp bug
This commit is contained in:
2026-03-30 19:52:18 -07:00
parent c8e42b3973
commit 6118c46192
17 changed files with 1015 additions and 486 deletions

View File

@@ -17,6 +17,7 @@ import {
getAffectedWordIdsForVideo,
refreshLexicalAggregates,
toDbMs,
toDbTimestamp,
} from './query-shared';
type CleanupVocabularyRow = {
@@ -351,7 +352,7 @@ export function upsertCoverArt(
)
.get(videoId) as { coverBlobHash: string | null } | undefined;
const sharedCoverBlobHash = findSharedCoverBlobHash(db, videoId, art.anilistId, art.coverUrl);
const fetchedAtMs = toDbMs(nowMs());
const fetchedAtMs = toDbTimestamp(nowMs());
const coverBlob = normalizeCoverBlobBytes(art.coverBlob);
const computedCoverBlobHash =
coverBlob && coverBlob.length > 0
@@ -444,7 +445,7 @@ export function updateAnimeAnilistInfo(
info.titleEnglish,
info.titleNative,
info.episodesTotal,
toDbMs(nowMs()),
toDbTimestamp(nowMs()),
row.anime_id,
);
}
@@ -452,7 +453,7 @@ export function updateAnimeAnilistInfo(
export function markVideoWatched(db: DatabaseSync, videoId: number, watched: boolean): void {
db.prepare('UPDATE imm_videos SET watched = ?, LAST_UPDATE_DATE = ? WHERE video_id = ?').run(
watched ? 1 : 0,
toDbMs(nowMs()),
toDbTimestamp(nowMs()),
videoId,
);
}