feat(recall): NoteRepository — findRecallCandidate + markRecallOpened + dismissRecall (#6 v0.2.3)
- findRecallCandidate(): 7일+ 안 본 + 30일+ dismiss 만료 + ai='done' + 마감 안 임박 + LIMIT 1
- markRecallOpened(id, now): last_recalled_at 갱신
- dismissRecall(id, now): recall_dismissed_at 갱신
- KST 보정 SQL date('now','+9 hours')
- 단위 +5 cases (empty/recent/old/dismiss expiry/exclude variants)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -217,6 +217,43 @@ export class NoteRepository {
|
||||
.run(nextRunAt, lastError.slice(0, 500), noteId);
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.2.3 #6 — 회상 후보 1건. 가장 오래된 후보 (created_at ASC) 우선.
|
||||
* - 7일 이상 안 본 노트 (last_recalled_at NULL 또는 7일 전 이전)
|
||||
* - 30일 이상 dismiss 만료 또는 dismiss 안 된 노트
|
||||
* - ai_status='done' + deleted_at IS NULL + due_date 임박 X (≥ today)
|
||||
* KST 보정: SQLite date('now') 는 UTC 라 +9 hours 항상 추가.
|
||||
*/
|
||||
findRecallCandidate(): Note | null {
|
||||
const row = this.db
|
||||
.prepare(
|
||||
`SELECT * FROM notes
|
||||
WHERE (last_recalled_at IS NULL OR last_recalled_at < date('now','+9 hours','-7 day'))
|
||||
AND (recall_dismissed_at IS NULL OR recall_dismissed_at < date('now','+9 hours','-30 day'))
|
||||
AND ai_status = 'done'
|
||||
AND deleted_at IS NULL
|
||||
AND (due_date IS NULL OR due_date >= date('now','+9 hours'))
|
||||
ORDER BY created_at ASC
|
||||
LIMIT 1`
|
||||
)
|
||||
.get() as Record<string, unknown> | undefined;
|
||||
return row ? this.hydrate(row) : null;
|
||||
}
|
||||
|
||||
/** v0.2.3 #6 — 회상 "열어보기" 시 last_recalled_at = now. */
|
||||
markRecallOpened(id: string, now: string): void {
|
||||
this.db
|
||||
.prepare(`UPDATE notes SET last_recalled_at = ?, updated_at = ? WHERE id = ?`)
|
||||
.run(now, now, id);
|
||||
}
|
||||
|
||||
/** v0.2.3 #6 — 회상 "더 이상" 시 recall_dismissed_at = now. 30일 후 재추천. */
|
||||
dismissRecall(id: string, now: string): void {
|
||||
this.db
|
||||
.prepare(`UPDATE notes SET recall_dismissed_at = ?, updated_at = ? WHERE id = ?`)
|
||||
.run(now, now, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* v0.2.3 #3 — AI prompt 의 vocabulary 후보. 사용 빈도 높은 태그 top-N.
|
||||
* source 무시 (AI+user 통합), kebab-case 통과한 것만 (한글/공백/대문자 제외).
|
||||
|
||||
Reference in New Issue
Block a user