From 62beeeab74b844b7a7819345c844114428450d96 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 4 Feb 2026 22:48:26 +0900 Subject: fix(study): apply 3 AM boundary to study API card queries findDueNewCardsForStudy and findDueReviewCardsForStudy were still using lte(cards.due, now) while findDueCards and countDueCards had been updated to use the study day boundary in d4489f2. This caused inconsistency between the displayed due count and actual cards returned by the study API. Co-Authored-By: Claude Opus 4.5 --- src/server/repositories/card.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/server/repositories') diff --git a/src/server/repositories/card.ts b/src/server/repositories/card.ts index 6202267..f546922 100644 --- a/src/server/repositories/card.ts +++ b/src/server/repositories/card.ts @@ -1,4 +1,4 @@ -import { and, eq, isNull, lt, lte, ne, sql } from "drizzle-orm"; +import { and, eq, isNull, lt, ne, sql } from "drizzle-orm"; import { getEndOfStudyDayBoundary } from "../../shared/date.js"; import { db } from "../db/index.js"; import { @@ -271,6 +271,7 @@ export const cardRepository: CardRepository = { now: Date, limit: number, ): Promise { + const boundary = getEndOfStudyDayBoundary(now); const result = await db .select() .from(cards) @@ -278,7 +279,7 @@ export const cardRepository: CardRepository = { and( eq(cards.deckId, deckId), isNull(cards.deletedAt), - lte(cards.due, now), + lt(cards.due, boundary), eq(cards.state, CardState.New), ), ) @@ -292,6 +293,7 @@ export const cardRepository: CardRepository = { now: Date, limit: number, ): Promise { + const boundary = getEndOfStudyDayBoundary(now); const result = await db .select() .from(cards) @@ -299,7 +301,7 @@ export const cardRepository: CardRepository = { and( eq(cards.deckId, deckId), isNull(cards.deletedAt), - lte(cards.due, now), + lt(cards.due, boundary), ne(cards.state, CardState.New), ), ) -- cgit v1.3-1-g0d28