diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-02-15 17:36:13 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-02-15 17:36:13 +0900 |
| commit | 84be23571d0e52f28abe52371939ce551e998760 (patch) | |
| tree | 0122f749ebc87b9c02af985de3f69f7e6b9e4e39 /src/server/routes/decks.ts | |
| parent | cbb45c8776444e90f26d27e53241cf5a9ba5ec4f (diff) | |
| download | kioku-84be23571d0e52f28abe52371939ce551e998760.tar.gz kioku-84be23571d0e52f28abe52371939ce551e998760.tar.zst kioku-84be23571d0e52f28abe52371939ce551e998760.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'src/server/routes/decks.ts')
| -rw-r--r-- | src/server/routes/decks.ts | 43 |
1 files changed, 33 insertions, 10 deletions
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", |
