diff options
| author | nsfisis <54318333+nsfisis@users.noreply.github.com> | 2026-02-13 20:23:31 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-13 20:23:31 +0900 |
| commit | ce6bbcea37d014b9575299d2d079fda7ccb5628d (patch) | |
| tree | 1fe3a43f1c7ab469bb0154a1495028cc42b414a0 /src/server/repositories/card.ts | |
| parent | 9a52e7ad3b2d46c523caf079794fdb7757375b91 (diff) | |
| parent | 1afb825860cd293b8065d51746f4b23e4e8dab5d (diff) | |
| download | kioku-ce6bbcea37d014b9575299d2d079fda7ccb5628d.tar.gz kioku-ce6bbcea37d014b9575299d2d079fda7ccb5628d.tar.zst kioku-ce6bbcea37d014b9575299d2d079fda7ccb5628d.zip | |
Merge pull request #15 from nsfisis/claude/remove-card-limit-10fVw
Remove newCardsPerDay limit and simplify card study logic
Diffstat (limited to 'src/server/repositories/card.ts')
| -rw-r--r-- | src/server/repositories/card.ts | 93 |
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, |
