feat(study): replace mock data with real backend service#51
Draft
MuenYu wants to merge 2 commits into
Draft
Conversation
- Add lib/study/service.ts with getStudyQueueForUser and submitReviewForUser - Implement SM-2 scheduling logic for spaced repetition - Create /api/study/queue and /api/study/review API endpoints - Refactor StudyView to fetch real cards from database - Implement infinite queue behavior with automatic refilling - Add empty state UI when no cards are due
32298f8 to
a511357
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaced the hardcoded mock vocabulary list in
StudyView.tsxwith a real backend service that fetches flashcards from the database and persists review results with spaced repetition scheduling.Changes
New Files
lib/study/service.ts: Backend service with:getStudyQueueForUser()- Fetches "pending + due" flashcards (state != suspended)submitReviewForUser()- Records reviews and applies SM-2 scheduling logicgetStudyStatsForUser()- Helper for due count/today's reviewsapp/api/study/queue/route.ts: API endpoint to fetch study cardsapp/api/study/review/route.ts: API endpoint to submit review resultsModified Files
app/(dashboard)/study/StudyView.tsx:MOCK_VOCAB_LISThardcoded dataremaining <= 5)Behavior
flashcards(dueAt, state, easeFactor, streak, etc.)Testing
Type Checking
✅ Passes TypeScript:
npx tsc --noEmit