feat: implement reading progress tracking system

Database & API:
- Enhanced ReadingHistory model with versionId field and unique constraint per user/version
- Created /api/user/reading-progress endpoint (GET/POST) for saving and retrieving progress
- Upsert operation ensures one reading position per user per Bible version

Bible Reader Features:
- Auto-save reading position after 2 seconds of inactivity
- Auto-restore last reading position on page load (respects URL parameters)
- Visual progress bar showing completion percentage based on chapters read
- Calculate progress across entire Bible (current chapter / total chapters)
- Client-side only loading to prevent hydration mismatches

Bug Fixes:
- Remove 200 version limit when loading "all versions" - now loads ALL versions
- Fix version selection resetting to favorite when user manually selects different version
- Transform books API response to include chaptersCount property
- Update service worker cache version to force client updates
- Add comprehensive SEO URL logging for debugging 404 issues

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-30 11:42:39 +00:00
parent 2ae2f029ec
commit 2a031cdf76
8 changed files with 300 additions and 14 deletions

View File

@@ -277,6 +277,7 @@ model UserPrayer {
model ReadingHistory {
id String @id @default(uuid())
userId String
versionId String // Bible version ID
bookId String
chapterNum Int
verseNum Int?
@@ -285,6 +286,8 @@ model ReadingHistory {
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId, viewedAt])
@@index([userId, versionId])
@@unique([userId, versionId]) // Only one reading position per user per version
}
model UserPreference {