feat(quota): added support for unlimited quota days#2797
feat(quota): added support for unlimited quota days#2797Roboroads wants to merge 2 commits intoseerr-team:developfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughBackend quota counting omits date filters when quota days are zero (unlimited). The UI adds an "Unlimited" ( Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User as Client (UI)
participant Frontend as Frontend
participant Backend as Server (User.getQuota)
participant DB as Database
User->>Frontend: selects quota days (0 = Unlimited)
Frontend->>Backend: GET /quota (quotaDays=0)
Backend->>DB: query used requests (shared joins/filters)
alt quotaDays truthy
Backend->>DB: add createdAt > :date filter
else quotaDays falsy (0)
Note right of DB: no date filter applied
end
DB-->>Backend: used counts
Backend-->>Frontend: quota response (counts, restricted flags)
Frontend->>User: render quota display (ICU plural -> "every day" or "every N days")
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
server/entity/User.ts (1)
317-335: LGTM! TV quota query refactored consistently with movie quota logic.The conditional
if (tvQuotaDays)check at lines 331-335 mirrors the movie quota behavior, ensuring unlimited time window whentvQuotaDays=0.Minor: The
leftJoin('request.seasons', 'seasons')at line 319 appears unused since the season count is computed via a separate subquery (lines 340-346). Consider removing it to avoid unnecessary join overhead.♻️ Optional refactor
const tvQuotaUsedQuery = requestRepository .createQueryBuilder('request') - .leftJoin('request.seasons', 'seasons') .leftJoin('request.requestedBy', 'requestedBy') .where('request.type = :requestType', {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@server/entity/User.ts` around lines 317 - 335, The leftJoin('request.seasons', 'seasons') in the TV quota query is unused (season counts are calculated via a separate subquery) and can be removed to avoid unnecessary join overhead; update the requestRepository.createQueryBuilder('request') TV query by deleting the leftJoin('request.seasons', 'seasons') call (refer to the tvQuotaUsedQuery variable and the TV quota-related logic) so the query still filters by request.type, requestedBy.id, status, and optional tvQuotaDays/tvQuotaStartDate but no longer performs the unused seasons join.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@server/entity/User.ts`:
- Around line 317-335: The leftJoin('request.seasons', 'seasons') in the TV
quota query is unused (season counts are calculated via a separate subquery) and
can be removed to avoid unnecessary join overhead; update the
requestRepository.createQueryBuilder('request') TV query by deleting the
leftJoin('request.seasons', 'seasons') call (refer to the tvQuotaUsedQuery
variable and the TV quota-related logic) so the query still filters by
request.type, requestedBy.id, status, and optional tvQuotaDays/tvQuotaStartDate
but no longer performs the unused seasons join.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: cead3e42-11b2-44b6-a7a6-88cc57886072
📒 Files selected for processing (4)
server/entity/User.tssrc/components/QuotaSelector/index.tsxsrc/components/RequestModal/QuotaDisplay/index.tsxsrc/i18n/locale/en.json
235d428 to
8148d1a
Compare
Description
I'm running Seerr on a "low storage" NAS. My friends and family have a limit on how much they can have stored on my server, when they are done watching they ask me to remove their downloads to free up remaining requests (and diskspace). This adds the option that there is no "per x days", but just "in total".
AI Usage: AI was used to figure out where to change the quota code, code is entirely written by myself.
How Has This Been Tested?
I've checked which parts of the application touches the quota API, they still work as the output isn't different. I changed a bit of the text in the quota display - it was not broken, just a little weird.
AI Usage: I have asked AI to review the code.
Screenshots / Logs (if applicable)
Checklist:
pnpm buildpnpm i18n:extractSummary by CodeRabbit
New Features
Improvements