Skip to content

fix(requests): stop editing a request from re-requesting covered seasons - #3379

Merged
gauthier-th merged 1 commit into
developfrom
fix/put-season-availability
Sep 23, 2026
Merged

gauthier-th merged 1 commit into
developfrom
fix/put-season-availability

Conversation

@fallenbagel

@fallenbagel fallenbagel commented Aug 12, 2026

Copy link
Copy Markdown
Member

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?

  • Via the attached unit test only

Screenshots / Logs (if applicable)

Checklist:

  • I have read and followed the contribution guidelines.
  • Disclosed any use of AI (see our policy)
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • Successful build pnpm build
  • Translation keys pnpm i18n:extract
  • Database migration (if required)

Summary by CodeRabbit

  • Improvements
    • TV season requests now skip seasons already available or covered by existing requests.
    • Existing selected seasons are preserved when adding new seasons.
    • Season updates retain selected seasons and add newly requested seasons as pending.
    • Availability and quota calculations account only for genuinely new seasons, including edits that add and remove seasons.
    • Requests with no new seasons return successfully without unnecessary processing.
    • Movie ownership changes now respect quota limits.
    • Request status changes enforce valid transitions and prevent updates to pending requests.
    • Concurrent request operations are handled safely to prevent conflicting updates.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Important

Review skipped

The 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 @coderabbitai full review to establish a new review baseline. No full review was started, and the last reviewed checkpoint was preserved.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 33cd57a8-60f6-402c-b887-52502dde017c

📥 Commits

Reviewing files that changed from the base of the PR and between 11378af and d0334f0.

📒 Files selected for processing (1)
  • server/routes/request.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

TV 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.

Changes

Request mutations and season availability

Layer / File(s) Summary
Season update classification
server/routes/request.ts
The route retains selected seasons, excludes media-covered seasons, appends uncovered seasons, removes omitted seasons, and recalculates TV quota.
Mutation state and locking
server/routes/request.ts
Update, delete, retry, approve, and decline operations use request locks. Retry and status transitions validate eligible request states.
Season update route coverage
server/routes/request.test.ts
Tests seed media seasons and verify exclusion, 202 responses, season retention, server updates, and net quota handling.

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
Loading

Merge Risk: ⚪ Minimal · up to d0334

The request mutation and season reconciliation changes appear mergeable with normal validation.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: preventing request edits from re-requesting seasons already covered by the media.

I’m a rabbit sorting seasons bright,
Covered ones leave the queue tonight.
New ones join the pending flow,
Quota counts the net rows we know.
Locked requests move in line,
202 marks the finished sign.

Comment @coderabbitai help to get the list of available commands.

Copilot AI lite review requested due to automatic review settings August 12, 2026 06:02
@fallenbagel
fallenbagel force-pushed the fix/put-season-availability branch from 247423f to 2391580 Compare August 12, 2026 06:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.seasons status) 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.

Comment thread server/routes/request.ts
Comment thread server/routes/request.test.ts
@fallenbagel fallenbagel changed the title fix/put season availability fix(requests): stop editing a request from re-requesting covered seasons Aug 12, 2026
@github-actions github-actions Bot added the merge conflict Cannot merge due to merge conflicts label Aug 12, 2026
@github-actions

This comment was marked as outdated.

@fallenbagel
fallenbagel force-pushed the fix/put-season-availability branch from 2391580 to 97e5636 Compare August 12, 2026 06:37
@github-actions github-actions Bot removed the merge conflict Cannot merge due to merge conflicts label Aug 12, 2026
@github-actions

This comment was marked as outdated.

@github-actions github-actions Bot added the merge conflict Cannot merge due to merge conflicts label Aug 13, 2026
Copilot AI review requested due to automatic review settings August 13, 2026 05:33
@fallenbagel
fallenbagel force-pushed the fix/put-season-availability branch from 97e5636 to b73a73c Compare August 13, 2026 05:33
@github-actions github-actions Bot removed the merge conflict Cannot merge due to merge conflicts label Aug 13, 2026
@fallenbagel
fallenbagel marked this pull request as ready for review August 13, 2026 05:34
@fallenbagel
fallenbagel requested a review from a team as a code owner August 13, 2026 05:34

This comment was marked as low quality.

@fallenbagel fallenbagel added this to the v3.5.0 milestone Aug 13, 2026
0xSysR3ll
0xSysR3ll previously approved these changes Aug 15, 2026
Copilot AI review requested due to automatic review settings August 25, 2026 20:04
@fallenbagel
fallenbagel force-pushed the fix/put-season-availability branch from 5efdb42 to 5b59037 Compare September 2, 2026 12:53
@M0NsTeRRR
M0NsTeRRR force-pushed the fix/put-season-availability branch from 5b59037 to 0abd46b Compare September 3, 2026 08:31
M0NsTeRRR
M0NsTeRRR previously approved these changes Sep 3, 2026
@fallenbagel
fallenbagel force-pushed the fix/put-season-availability branch from 0abd46b to 5e879b3 Compare September 3, 2026 10:22
0xSysR3ll
0xSysR3ll previously approved these changes Sep 5, 2026
@fallenbagel
fallenbagel dismissed stale reviews from 0xSysR3ll and M0NsTeRRR via 1d731a8 September 5, 2026 21:45
@fallenbagel
fallenbagel force-pushed the fix/put-season-availability branch from 5e879b3 to 1d731a8 Compare September 5, 2026 21:45
coderabbitai[bot]

This comment was marked as resolved.

@fallenbagel
fallenbagel force-pushed the fix/put-season-availability branch from 1d731a8 to 11378af Compare September 5, 2026 22:57
gauthier-th
gauthier-th previously approved these changes Sep 14, 2026

@gauthier-th gauthier-th left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from fix/put-quota-check to develop September 23, 2026 11:58
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.
@gauthier-th
gauthier-th force-pushed the fix/put-season-availability branch from 3672aea to 526e065 Compare September 23, 2026 11:58
@gauthier-th
gauthier-th merged commit 10483e2 into develop Sep 23, 2026
15 checks passed
@gauthier-th
gauthier-th deleted the fix/put-season-availability branch September 23, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants