Skip to content

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

Open
fallenbagel wants to merge 1 commit into
fix/put-quota-checkfrom
fix/put-season-availability
Open

fix(requests): stop editing a request from re-requesting covered seasons#3379
fallenbagel wants to merge 1 commit into
fix/put-quota-checkfrom
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 included in an existing request.
    • Existing requested seasons are preserved when adding new seasons.
    • Season updates retain selected seasons and add newly requested seasons as pending.
    • Availability and quota calculations now account only for genuinely new seasons.
    • Requests with no new seasons are completed successfully without unnecessary processing.
    • Season availability updates now return successfully when all requested seasons are already covered.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0c08678b-8cc1-4aa6-83c3-53477577a2bc

📥 Commits

Reviewing files that changed from the base of the PR and between 97e5636 and b73a73c.

📒 Files selected for processing (2)
  • server/routes/request.test.ts
  • server/routes/request.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • server/routes/request.test.ts
  • server/routes/request.ts

📝 Walkthrough

Walkthrough

TV request updates now distinguish retained request seasons from seasons already available on media. Covered seasons are excluded, new seasons are appended, and quota calculations use the resulting season set. Tests cover responses, retention, server updates, and quota behavior.

Changes

TV season availability

Layer / File(s) Summary
Season update classification
server/routes/request.ts
The route retains selected request seasons, excludes seasons already covered by media, appends uncovered seasons, updates removals, and calculates quota from the resulting seasons.
Season update route coverage
server/routes/request.test.ts
Tests seed media seasons and verify season exclusion, 202 responses, retention, server updates, and quota handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Mergeability Score: ⚪ Minimal · up to b73a7

This change prevents covered seasons from being re-requested during edits and adjusts quota calculation to the seasons retained by the request; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant RequestRoute
  participant TVMedia
  participant TVQuota
  RequestRoute->>TVMedia: Read available media seasons
  TVMedia-->>RequestRoute: Return covered seasons
  RequestRoute->>RequestRoute: Retain owned seasons and append uncovered seasons
  RequestRoute->>TVQuota: Calculate quota from resulting seasons
Loading

Possibly related PRs

Poem

I’m a rabbit guarding seasons bright,
Covered ones hop out of sight.
New ones wait in pending rows,
Quota counts the request now knows.
202 marks the work as done—
Each season safely won.

🚥 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 and concisely describes the main change: preventing requests from re-requesting seasons already covered by available media.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

3 participants