Fix mark next episode query to use JOIN instead of IN clause - #30
Conversation
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: willtho89 <4933503+willtho89@users.noreply.github.com>
Co-authored-by: willtho89 <4933503+willtho89@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
backend/tests/test_mark_next_episode_fix.py:1
- This test file only contains documentation without actually testing the fix. Consider adding integration tests that verify the correct episode is marked as watched when multiple episodes exist, ensuring episode 6 is marked when 5 episodes are already watched rather than episode 1.
"""Test for the fix to mark next episode as watched query.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This will likely not work with seasons, will it? Eh watched last episode of a season (S01e09), the next episode should be episode one of the next season (S02e01) |
|
@copilot Check my comment |
The implementation already handles seasons correctly. The query orders episodes by If you've watched S01E09 and S02E01 is released, the code will correctly identify S02E01 as the next unwatched episode. The loop finds the first episode in order that's not in the watched set, which naturally handles season transitions.
Checked and replied to your previous comment. The implementation correctly handles season transitions. |
The "Mark next episode as watched" button was incorrectly marking the first episode instead of the next unwatched episode (e.g., marking episode 1 when episodes 1-5 were watched, instead of episode 6).
Root Cause
The query fetching watched episodes used
.in_()with a list comprehension instead of an explicit JOIN, inconsistent with the working pattern in_get_show_progress_bulk().Changes
mark_watchlist_item_watched: Changed from.in_()filter to explicit JOIN matching_get_show_progress_bulk()patternshow_media_item_id,air_date, andseason_numberto ensure only relevant episodes are consideredBefore
After
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.