fix(requests): stop editing a request from re-requesting covered seasons - #3379
Conversation
|
Important Review skippedThe saved review history does not include the base for the last reviewed commit. This saved history cannot establish the base for an incremental review. Comment You can disable this status message by setting the Use the checkbox below for a quick retry:
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughTV request routes now serialize mutations and enforce valid request states. TV request edits retain selected seasons, exclude seasons covered by media, append uncovered seasons, and calculate quota from the resulting season set. Tests cover these behaviors. ChangesRequest mutations and season availability
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant RequestRoute
participant TVMedia
participant TVQuota
RequestRoute->>TVMedia: Read media season availability
TVMedia-->>RequestRoute: Return covered seasons
RequestRoute->>RequestRoute: Retain selected seasons and append uncovered seasons
RequestRoute->>TVQuota: Calculate quota from resulting seasons
Merge Risk: ⚪ Minimal · up to The request mutation and season reconciliation changes appear mergeable with normal validation. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
I’m a rabbit sorting seasons bright, Comment |
247423f to
2391580
Compare
There was a problem hiding this comment.
Pull request overview
This PR adjusts the TV request update (PUT /request/:requestId) logic to prevent adding seasons that are already covered by existing season availability, and updates the test suite to validate the new behavior.
Changes:
- Exclude “covered” seasons (based on
Media.seasonsstatus) from being newly added to an existing TV request during updates. - Update quota calculations to use the post-filter season count for the request update path.
- Add targeted tests for season-availability behavior during request updates.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| server/routes/request.ts | Filters out covered seasons when updating TV requests; recalculates required seasons accordingly. |
| server/routes/request.test.ts | Adds helpers and new tests covering season-availability behavior in PUT updates. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This comment was marked as outdated.
This comment was marked as outdated.
2391580 to
97e5636
Compare
This comment was marked as outdated.
This comment was marked as outdated.
97e5636 to
b73a73c
Compare
5efdb42 to
5b59037
Compare
5b59037 to
0abd46b
Compare
0abd46b to
5e879b3
Compare
1d731a8
5e879b3 to
1d731a8
Compare
1d731a8 to
11378af
Compare
11378af to
d0334f0
Compare
d0334f0 to
3672aea
Compare
Creating a request skips seasons the media already has, but editing one only looked at seasons held by other requests, so an edit could add a season that was already available and charge the owner's quota for it. The availability check applies to seasons being added, not to the ones the request already holds, otherwise editing an approved request would drop its own seasons the moment they started processing. The quota arithmetic now counts the seasons the edit actually ends up with rather than assuming that is every season it asked for.
3672aea to
526e065
Compare
Description
Creating a request skips seasons the media already has, but editing one only looked at seasons other requests hold. An edit could therefore add a season that was already available and charge the owner's quota for it.
The availability check applies only to seasons being added, not to the ones the request already holds. This matters because a request's own seasons stop being unknown as soon as it is approved, so treating them the same way would drop them from the request the moment they started processing.
This sits on the quota check PR below it and updates its arithmetic, which until now could assume the edit ends up with every season it asked for. That is no longer true once covered seasons are dropped, so the quota is charged against the seasons the edit actually ends up with.
How Has This Been Tested?
Screenshots / Logs (if applicable)
Checklist:
pnpm buildpnpm i18n:extractSummary by CodeRabbit