Files
bilin/src/main/db/repositories/pomodoro-daily.repo.ts
T
bing d4122c8f95 feat: ship v0.9.0 with pomodoro, achievements, and injection history
Add pomodoro timer with goal notifications, writing streak milestones, and knowledge injection logging with UI previews across AI writing flows.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 19:15:52 +08:00

26 lines
929 B
TypeScript

import type { DatabaseSync } from 'node:sqlite'
import { localDateString } from '../../services/writing-date.util'
export class PomodoroDailyRepository {
constructor(private db: DatabaseSync) {}
recordComplete(bookId: string, wordDelta: number, date = localDateString()): void {
this.db
.prepare(
`INSERT INTO pomodoro_daily (date, book_id, completed_count, total_words)
VALUES (?, ?, 1, ?)
ON CONFLICT(date, book_id) DO UPDATE SET
completed_count = completed_count + 1,
total_words = total_words + excluded.total_words`
)
.run(date, bookId, wordDelta)
}
getTodayCount(bookId: string, date = localDateString()): number {
const row = this.db
.prepare('SELECT completed_count FROM pomodoro_daily WHERE date = ? AND book_id = ?')
.get(date, bookId) as { completed_count: number } | undefined
return row?.completed_count ?? 0
}
}