From 84be23571d0e52f28abe52371939ce551e998760 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 15 Feb 2026 17:36:13 +0900 Subject: feat(deck): add progress bar showing review/total ratio on deck list Add totalCardCount and reviewCardCount to deck API responses and display a progress bar on the home page for each deck with cards. Co-Authored-By: Claude Opus 4.6 --- src/server/routes/decks.ts | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'src/server/routes/decks.ts') diff --git a/src/server/routes/decks.ts b/src/server/routes/decks.ts index dcf758a..069b933 100644 --- a/src/server/routes/decks.ts +++ b/src/server/routes/decks.ts @@ -30,11 +30,20 @@ export function createDecksRouter(deps: DeckDependencies) { const now = new Date(); const decksWithDueCount = await Promise.all( decks.map(async (deck) => { - const [dueCardCount, newCardCount] = await Promise.all([ - cardRepo.countDueCards(deck.id, now), - cardRepo.countNewCards(deck.id), - ]); - return { ...deck, dueCardCount, newCardCount }; + const [dueCardCount, newCardCount, totalCardCount, reviewCardCount] = + await Promise.all([ + cardRepo.countDueCards(deck.id, now), + cardRepo.countNewCards(deck.id), + cardRepo.countTotalCards(deck.id), + cardRepo.countReviewStateCards(deck.id), + ]); + return { + ...deck, + dueCardCount, + newCardCount, + totalCardCount, + reviewCardCount, + }; }), ); return c.json({ decks: decksWithDueCount }, 200); @@ -61,12 +70,26 @@ export function createDecksRouter(deps: DeckDependencies) { } const now = new Date(); - const [dueCardCount, newCardCount] = await Promise.all([ - cardRepo.countDueCards(deck.id, now), - cardRepo.countNewCards(deck.id), - ]); + const [dueCardCount, newCardCount, totalCardCount, reviewCardCount] = + await Promise.all([ + cardRepo.countDueCards(deck.id, now), + cardRepo.countNewCards(deck.id), + cardRepo.countTotalCards(deck.id), + cardRepo.countReviewStateCards(deck.id), + ]); - return c.json({ deck: { ...deck, dueCardCount, newCardCount } }, 200); + return c.json( + { + deck: { + ...deck, + dueCardCount, + newCardCount, + totalCardCount, + reviewCardCount, + }, + }, + 200, + ); }) .put( "/:id", -- cgit v1.3-1-g0d28