Explorar o código

Fix: Rate button now works on reading log

Fixed the non-functional rate button in the reading log by correcting
the ID being passed to the rating API.

Problem:
- Rate button was passing book_id to promptRating() function
- API endpoint expects session_id (/api/sessions/{session_id}/rating)
- Clicking the Rate button would fail with 404 error

Solution:
- Added session_id to recent_books data structure in stats service
- Updated JavaScript to pass session_id instead of book_id to promptRating()

Changes:
- app/services/stats.py:252 - Added session_id to recent books response
- app/static/js/reading-log.js:170 - Changed onclick to use session_id

Note: Audiobookshelf does not have a built-in rating system as of 2025.
Ratings are stored locally in Dewy Oracle only.

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Brad Lance hai 3 meses
pai
achega
ed4a37ac2a
Modificáronse 2 ficheiros con 2 adicións e 1 borrados
  1. 1 0
      app/services/stats.py
  2. 1 1
      app/static/js/reading-log.js

+ 1 - 0
app/services/stats.py

@@ -249,6 +249,7 @@ class ReadingStatsService:
                 listening_duration = round(book.duration / 3600, 1)
 
             recent.append({
+                "session_id": session.id,  # Session ID for rating updates
                 "book_id": book.id,
                 "title": book.title,
                 "author": book.author,

+ 1 - 1
app/static/js/reading-log.js

@@ -167,7 +167,7 @@ function renderRecentBooks(recentBooks) {
                     </div>
                     <div class="book-rating">
                         <span class="rating-stars">${ratingStars}</span>
-                        <button class="btn btn-small" onclick="promptRating(${book.book_id})">Rate</button>
+                        <button class="btn btn-small" onclick="promptRating(${book.session_id})">Rate</button>
                     </div>
                 </div>
             </div>