aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/server/repositories/card.ts
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-02-12 14:54:18 +0000
committerClaude <noreply@anthropic.com>2026-02-12 14:54:18 +0000
commit1afb825860cd293b8065d51746f4b23e4e8dab5d (patch)
tree1fe3a43f1c7ab469bb0154a1495028cc42b414a0 /src/server/repositories/card.ts
parent9a52e7ad3b2d46c523caf079794fdb7757375b91 (diff)
downloadkioku-1afb825860cd293b8065d51746f4b23e4e8dab5d.tar.gz
kioku-1afb825860cd293b8065d51746f4b23e4e8dab5d.tar.zst
kioku-1afb825860cd293b8065d51746f4b23e4e8dab5d.zip
feat: 学習カード数の上限を撤廃
REVIEW_CARDS_LIMIT(復習カード80枚制限)とnewCardsPerDay(1日の新規カード制限) を削除し、期日が来たすべてのカードを制限なく返すように変更。 削除した主な要素: - REVIEW_CARDS_LIMIT定数とカード取得時のlimitパラメータ - newCardsPerDayフィールド(DB schema, 型定義, Zod schema, sync, CRDT) - countDueNewCards, countDueReviewCards, findDueNewCardsForStudy, findDueReviewCardsForStudy(CardRepository) - countTodayNewCardReviews(ReviewLogRepository) - デッキルートからのReviewLogRepository依存 https://claude.ai/code/session_018hrEJ9vg3RPoeAPyEc17gS
Diffstat (limited to 'src/server/repositories/card.ts')
-rw-r--r--src/server/repositories/card.ts93
1 files changed, 5 insertions, 88 deletions
diff --git a/src/server/repositories/card.ts b/src/server/repositories/card.ts
index d382f4d..0f1ef79 100644
--- a/src/server/repositories/card.ts
+++ b/src/server/repositories/card.ts
@@ -1,4 +1,4 @@
-import { and, eq, isNull, lt, ne, sql } from "drizzle-orm";
+import { and, eq, isNull, lt, sql } from "drizzle-orm";
import { getEndOfStudyDayBoundary } from "../../shared/date.js";
import { db } from "../db/index.js";
import {
@@ -185,11 +185,7 @@ export const cardRepository: CardRepository = {
return result.length > 0;
},
- async findDueCards(
- deckId: string,
- now: Date,
- limit: number,
- ): Promise<Card[]> {
+ async findDueCards(deckId: string, now: Date): Promise<Card[]> {
const boundary = getEndOfStudyDayBoundary(now);
const result = await db
.select()
@@ -201,8 +197,7 @@ export const cardRepository: CardRepository = {
lt(cards.due, boundary),
),
)
- .orderBy(cards.due)
- .limit(limit);
+ .orderBy(cards.due);
return result;
},
@@ -221,44 +216,11 @@ export const cardRepository: CardRepository = {
return result[0]?.count ?? 0;
},
- async countDueNewCards(deckId: string, now: Date): Promise<number> {
- const boundary = getEndOfStudyDayBoundary(now);
- const result = await db
- .select({ count: sql<number>`count(*)::int` })
- .from(cards)
- .where(
- and(
- eq(cards.deckId, deckId),
- isNull(cards.deletedAt),
- lt(cards.due, boundary),
- eq(cards.state, CardState.New),
- ),
- );
- return result[0]?.count ?? 0;
- },
-
- async countDueReviewCards(deckId: string, now: Date): Promise<number> {
- const boundary = getEndOfStudyDayBoundary(now);
- const result = await db
- .select({ count: sql<number>`count(*)::int` })
- .from(cards)
- .where(
- and(
- eq(cards.deckId, deckId),
- isNull(cards.deletedAt),
- lt(cards.due, boundary),
- ne(cards.state, CardState.New),
- ),
- );
- return result[0]?.count ?? 0;
- },
-
async findDueCardsWithNoteData(
deckId: string,
now: Date,
- limit: number,
): Promise<CardWithNoteData[]> {
- const dueCards = await this.findDueCards(deckId, now, limit);
+ const dueCards = await this.findDueCards(deckId, now);
const cardsWithNoteData: CardWithNoteData[] = [];
@@ -292,56 +254,11 @@ export const cardRepository: CardRepository = {
async findDueCardsForStudy(
deckId: string,
now: Date,
- limit: number,
): Promise<CardForStudy[]> {
- const dueCards = await this.findDueCards(deckId, now, limit);
+ const dueCards = await this.findDueCards(deckId, now);
return enrichCardsForStudy(dueCards);
},
- async findDueNewCardsForStudy(
- deckId: string,
- now: Date,
- limit: number,
- ): Promise<CardForStudy[]> {
- const boundary = getEndOfStudyDayBoundary(now);
- const result = await db
- .select()
- .from(cards)
- .where(
- and(
- eq(cards.deckId, deckId),
- isNull(cards.deletedAt),
- lt(cards.due, boundary),
- eq(cards.state, CardState.New),
- ),
- )
- .orderBy(cards.due)
- .limit(limit);
- return enrichCardsForStudy(result);
- },
-
- async findDueReviewCardsForStudy(
- deckId: string,
- now: Date,
- limit: number,
- ): Promise<CardForStudy[]> {
- const boundary = getEndOfStudyDayBoundary(now);
- const result = await db
- .select()
- .from(cards)
- .where(
- and(
- eq(cards.deckId, deckId),
- isNull(cards.deletedAt),
- lt(cards.due, boundary),
- ne(cards.state, CardState.New),
- ),
- )
- .orderBy(cards.due)
- .limit(limit);
- return enrichCardsForStudy(result);
- },
-
async updateFSRSFields(
id: string,
deckId: string,