chore(kobo): fix invalidateSnapshot log format and remove unbounded bookIds field

The debug log in invalidateSnapshot did not follow the project logging
convention ([event] [phase] key=value ... - message) and logged all
reset book IDs, which could produce unbounded single-line output for
large libraries.

Fix the event name, add the [end] phase marker, add durationMs, drop
the bookIds field, and remove the no-snapshot early-return log (noisy
no-op path).
This commit is contained in:
neon
2026-06-08 21:48:21 +00:00
parent 9de47fe67d
commit a1b417ccb8
@@ -129,13 +129,11 @@ export class KoboSyncService {
}
async invalidateSnapshot(userId: number) {
const start = Date.now();
const snapshot = await this.db.query.koboLibrarySnapshots.findFirst({
where: eq(schema.koboLibrarySnapshots.userId, userId),
});
if (!snapshot) {
this.logger.debug(`[kobo.snapshot] invalidate skipped userId=${userId} reason=no_snapshot`);
return;
}
if (!snapshot) return;
const resetRows = await this.db
.update(schema.koboSnapshotBooks)
@@ -144,7 +142,7 @@ export class KoboSyncService {
.returning({ bookId: schema.koboSnapshotBooks.bookId });
this.logger.debug(
`[kobo.snapshot] invalidated userId=${userId} snapshotId=${snapshot.id} resetSyncedCount=${resetRows.length} bookIds=${resetRows.map((row) => row.bookId).join(',') || 'none'}`,
`[kobo.snapshot.invalidate] [end] userId=${userId} snapshotId=${snapshot.id} durationMs=${Date.now() - start} resetSyncedCount=${resetRows.length} - snapshot invalidated`,
);
}