aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/server
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-02-02 12:22:03 +0000
committerClaude <noreply@anthropic.com>2026-02-02 12:22:03 +0000
commitd4489f24a05911d1395e8473fe86c3442d9397ee (patch)
tree3f302c9c531c7ba25e2c5ad74c44b086df03a0d7 /src/server
parentc20922a1aa339e34b4bed3747222f4b9d9941cd6 (diff)
downloadkioku-d4489f24a05911d1395e8473fe86c3442d9397ee.tar.gz
kioku-d4489f24a05911d1395e8473fe86c3442d9397ee.tar.zst
kioku-d4489f24a05911d1395e8473fe86c3442d9397ee.zip
fix(study): use date-based comparison with 3 AM boundary for due cards
Instead of comparing due timestamps exactly (card.due <= now), compare against the next 3 AM boundary so all cards due within the current study day appear at once. This prevents new cards from trickling in throughout the day when FSRS fuzz spreads due times. https://claude.ai/code/session_01FeDztLcyGofd6nxh8ct7a3
Diffstat (limited to 'src/server')
-rw-r--r--src/server/repositories/card.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/server/repositories/card.ts b/src/server/repositories/card.ts
index ac03bc6..2f14149 100644
--- a/src/server/repositories/card.ts
+++ b/src/server/repositories/card.ts
@@ -1,4 +1,5 @@
-import { and, eq, isNull, lte, sql } from "drizzle-orm";
+import { and, eq, isNull, lt, sql } from "drizzle-orm";
+import { getEndOfStudyDayBoundary } from "../../shared/date.js";
import { db } from "../db/index.js";
import {
CardState,
@@ -189,6 +190,7 @@ export const cardRepository: CardRepository = {
now: Date,
limit: number,
): Promise<Card[]> {
+ const boundary = getEndOfStudyDayBoundary(now);
const result = await db
.select()
.from(cards)
@@ -196,7 +198,7 @@ export const cardRepository: CardRepository = {
and(
eq(cards.deckId, deckId),
isNull(cards.deletedAt),
- lte(cards.due, now),
+ lt(cards.due, boundary),
),
)
.orderBy(cards.due)
@@ -205,6 +207,7 @@ export const cardRepository: CardRepository = {
},
async countDueCards(deckId: string, now: Date): Promise<number> {
+ const boundary = getEndOfStudyDayBoundary(now);
const result = await db
.select({ count: sql<number>`count(*)::int` })
.from(cards)
@@ -212,7 +215,7 @@ export const cardRepository: CardRepository = {
and(
eq(cards.deckId, deckId),
isNull(cards.deletedAt),
- lte(cards.due, now),
+ lt(cards.due, boundary),
),
);
return result[0]?.count ?? 0;