From 1afb825860cd293b8065d51746f4b23e4e8dab5d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 12 Feb 2026 14:54:18 +0000 Subject: feat: 学習カード数の上限を撤廃 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/server/repositories/card.ts | 93 +++-------------------------------------- 1 file changed, 5 insertions(+), 88 deletions(-) (limited to 'src/server/repositories/card.ts') 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 { + async findDueCards(deckId: string, now: Date): Promise { 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 { - const boundary = getEndOfStudyDayBoundary(now); - const result = await db - .select({ count: sql`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 { - const boundary = getEndOfStudyDayBoundary(now); - const result = await db - .select({ count: sql`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 { - 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 { - 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 { - 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 { - 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, -- cgit v1.3-1-g0d28