From cea7703ac440c38636ce2abd5baab35a23d05843 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 15 Feb 2026 16:45:35 +0900 Subject: feat(deck): display new card count on deck detail page Add newCardCount alongside Total and Due stats in the deck detail view, queried from cards with state=New via a new countNewCards repository method. Co-Authored-By: Claude Opus 4.6 --- src/server/routes/decks.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/server/routes/decks.ts') diff --git a/src/server/routes/decks.ts b/src/server/routes/decks.ts index ed7077e..dcf758a 100644 --- a/src/server/routes/decks.ts +++ b/src/server/routes/decks.ts @@ -30,8 +30,11 @@ export function createDecksRouter(deps: DeckDependencies) { const now = new Date(); const decksWithDueCount = await Promise.all( decks.map(async (deck) => { - const dueCardCount = await cardRepo.countDueCards(deck.id, now); - return { ...deck, dueCardCount }; + const [dueCardCount, newCardCount] = await Promise.all([ + cardRepo.countDueCards(deck.id, now), + cardRepo.countNewCards(deck.id), + ]); + return { ...deck, dueCardCount, newCardCount }; }), ); return c.json({ decks: decksWithDueCount }, 200); @@ -58,9 +61,12 @@ export function createDecksRouter(deps: DeckDependencies) { } const now = new Date(); - const dueCardCount = await cardRepo.countDueCards(deck.id, now); + const [dueCardCount, newCardCount] = await Promise.all([ + cardRepo.countDueCards(deck.id, now), + cardRepo.countNewCards(deck.id), + ]); - return c.json({ deck: { ...deck, dueCardCount } }, 200); + return c.json({ deck: { ...deck, dueCardCount, newCardCount } }, 200); }) .put( "/:id", -- cgit v1.3-1-g0d28