aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/server/routes/decks.ts
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-02-15 16:45:35 +0900
committernsfisis <nsfisis@gmail.com>2026-02-15 16:45:35 +0900
commitcea7703ac440c38636ce2abd5baab35a23d05843 (patch)
tree38de7bdf13a6b4b006319ee7800206eab9e35215 /src/server/routes/decks.ts
parent65fcf4111bc64267624b4e348bb704d006de5327 (diff)
downloadkioku-cea7703ac440c38636ce2abd5baab35a23d05843.tar.gz
kioku-cea7703ac440c38636ce2abd5baab35a23d05843.tar.zst
kioku-cea7703ac440c38636ce2abd5baab35a23d05843.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'src/server/routes/decks.ts')
-rw-r--r--src/server/routes/decks.ts14
1 files changed, 10 insertions, 4 deletions
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",