aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/server/routes/study.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/routes/study.ts')
-rw-r--r--src/server/routes/study.ts16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/server/routes/study.ts b/src/server/routes/study.ts
index d978a6a..efd450c 100644
--- a/src/server/routes/study.ts
+++ b/src/server/routes/study.ts
@@ -51,9 +51,21 @@ export function createStudyRouter(deps: StudyDependencies) {
}
const now = new Date();
- const dueCards = await cardRepo.findDueCardsForStudy(deckId, now, 100);
- return c.json({ cards: dueCards }, 200);
+ // Calculate new card budget based on today's already-reviewed new cards
+ const reviewedNewCards = await reviewLogRepo.countTodayNewCardReviews(
+ deckId,
+ now,
+ );
+ const newCardBudget = Math.max(0, deck.newCardsPerDay - reviewedNewCards);
+
+ // Fetch new cards (limited) and review cards separately
+ const [newCards, reviewCards] = await Promise.all([
+ cardRepo.findDueNewCardsForStudy(deckId, now, newCardBudget),
+ cardRepo.findDueReviewCardsForStudy(deckId, now, 100),
+ ]);
+
+ return c.json({ cards: [...newCards, ...reviewCards] }, 200);
})
.post(
"/:cardId",