Skip to content

feat(override-rules): add certifications to override rules - #3335

Open
aussierk wants to merge 4 commits into
seerr-team:developfrom
aussierk:feature-add-certifications-to-override-rules
Open

feat(override-rules): add certifications to override rules#3335
aussierk wants to merge 4 commits into
seerr-team:developfrom
aussierk:feature-add-certifications-to-override-rules

Conversation

@aussierk

@aussierk aussierk commented Aug 1, 2026

Copy link
Copy Markdown

Description

I added the ability to implement an override-rule condition for the certification/parental-rating of the content being requested. It is integrated to the existing system for override-rules allowing users to set conditions to modify the root directory, the tags, and/or the quality profile of the content that is requested.

To achieve this, I added the rule that required content to match any of the selected certification values in the rule to meet the condition. This required that the media be parsed for release dates, iso_3166_1 and the certification or content_rating as part of the existing tmdbMedia call that is made during a request.

I needed to add a certification value to the override rules table in the database so that the condition could be registered alongside the other override rule conditions and I then added the certification condition to the UI so that users could set the condition as part of the existing menu. I refactored an existing unused UI CertificationSelector element to match the required values and interface used for the override rule.

It facilitates the sorting of content by rating to allow the sorting of kids content and adult or teen content into different libraries more easily without needing two radarr or sonarr instances.

How Has This Been Tested?

I ran pnpm test (133 passing), pnpm typecheck, pnpm lint and pnpm build all pass.

I tested against a local seer instance connected to radarr and sonarr. I created two local users, one admin, and one regular user without privileges.
  • I created a rule with a certification condition and ensured it persisted correctly through a refresh and a restart.
  • I created a request that would match the certification condition and verified that the rule was applied.
  • I created a request that would not match the certification condition and verified that the rule was not applied.
  • I modified the override rule and ensured that the changes persisted and applied correctly after a restart.
  • I created a rule with multiple conditions including genre, user and language to ensure that the rule was correctly evaluated.
  • I deleted a rule and ensured it did not continue to be applied.
  • Ran the SQLite migration on a real database and the Postgres one on a fresh
    database

Screenshots / Logs (if applicable)

image image image

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)

AI Disclosure: I used AI assistance for code review and small amount of debugging but all code was written and designed by myself.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Override rules can now match movie and TV certifications by country and rating.
    • Added searchable, multi-select certification support when creating or editing override rules.
    • Override rule listings display configured certifications with localized region names and rating details.
  • Improvements

    • Certification matching now prioritizes more specific rules.
    • Updated English labels and sign-in wording for clarity.

@aussierk
aussierk requested a review from a team as a code owner August 1, 2026 15:06
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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: Pro Plus

Run ID: 02342ac0-a3bb-4b13-9085-37c318c98180

📥 Commits

Reviewing files that changed from the base of the PR and between 0103458 and e3ea73c.

📒 Files selected for processing (1)
  • src/i18n/locale/en.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/i18n/locale/en.json

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


📝 Walkthrough

Walkthrough

Override rules now support country-specific movie and TV certifications. Certifications are stored in the database, accepted by the API, matched during request processing, and managed through the settings interface.

Changes

Certification-based override rules

Layer / File(s) Summary
Persist and expose certification conditions
server/entity/OverrideRule.ts, server/migration/..., server/routes/overrideRule.ts
Override rules store nullable certification values. Create and update requests accept and persist them.
Match certification-specific rules
server/entity/MediaRequest.ts
Rule filtering compares certifications by country and includes certification when prioritizing matching rules.
Configure and display certifications
src/components/Selector/..., src/components/Settings/OverrideRule/..., src/i18n/locale/en.json
The UI supports searchable multi-select certifications, submits certification conditions, renders localized rule values, and updates related labels.

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

Merge Risk: ⚪ Minimal · up to e3ea7

This change adds certification-based override-rule conditions for routing requested content. The reported validation covers persistence, matching and non-matching requests, migrations, and related rule combinations; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant OverrideRuleModal
  participant OverrideRuleRoute
  participant OverrideRule
  participant MediaRequest
  User->>OverrideRuleModal: select certifications
  OverrideRuleModal->>OverrideRuleRoute: submit certification condition
  OverrideRuleRoute->>OverrideRule: create or update rule
  MediaRequest->>OverrideRule: load override rules
  MediaRequest->>MediaRequest: compare and prioritize certifications
Loading

Poem

A rabbit selects ratings bright,
Stores each code by country right.
Matching rules use the rating,
Tiles display the saved setting.
“PG!” says the rabbit, ears held high.

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The localization change from “Sign In” to “Sign in to your account” is unrelated to certification-based override rules. Remove the unrelated sign-in localization change or move it to a separate pull request.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: adding certifications to override rules.
Linked Issues check ✅ Passed The PR adds certification conditions across matching, persistence, API, and UI, enabling rating-based routing requested in issue #301.

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/components/Selector/CertificationSelector.tsx (1)

57-71: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated country-name-resolution logic into a shared utility. Both sites derive a localized country name (with subdivision support) from an ISO code using the same split('-') + intl.formatDisplayName + try/catch fallback pattern.

  • src/components/Selector/CertificationSelector.tsx#L57-L71: keep this as the canonical implementation, but extract it into a shared exported helper (for example src/utils/certificationCountryName.ts) that accepts intl and the country code.
  • src/components/Settings/OverrideRule/OverrideRuleTiles.tsx#L227-L256: replace the inline try/catch block with a call to the shared helper instead of re-implementing the same logic.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/Selector/CertificationSelector.tsx` around lines 57 - 71,
Extract the getCountryName logic from
src/components/Selector/CertificationSelector.tsx lines 57-71 into a shared
exported helper that accepts intl and the country code, preserving subdivision
formatting and try/catch fallback behavior; update CertificationSelector.tsx to
use it. In src/components/Settings/OverrideRule/OverrideRuleTiles.tsx lines
227-256, remove the duplicated inline resolution logic and call the shared
helper instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/Settings/OverrideRule/OverrideRuleModal.tsx`:
- Around line 421-442: Update the service select onChange handler in
OverrideRuleModal to reset certification to null whenever the selected service
switches between Radarr, Sonarr, or no service, alongside the existing
radarrServiceId and sonarrServiceId updates. Preserve the current validation
reset behavior for the no-service branch.

In `@src/components/Settings/OverrideRule/OverrideRuleTiles.tsx`:
- Around line 227-256: Add a stable, unique key to each certification item span
returned by the map callback in the certification rendering within
OverrideRuleTiles. Use the entry value or another combination that uniquely
identifies each certification, while leaving the displayed country and
certification text unchanged.

---

Nitpick comments:
In `@src/components/Selector/CertificationSelector.tsx`:
- Around line 57-71: Extract the getCountryName logic from
src/components/Selector/CertificationSelector.tsx lines 57-71 into a shared
exported helper that accepts intl and the country code, preserving subdivision
formatting and try/catch fallback behavior; update CertificationSelector.tsx to
use it. In src/components/Settings/OverrideRule/OverrideRuleTiles.tsx lines
227-256, remove the duplicated inline resolution logic and call the shared
helper instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0f234804-85f7-4560-bdff-c1ce09248665

📥 Commits

Reviewing files that changed from the base of the PR and between bd491c7 and 2dea89d.

📒 Files selected for processing (10)
  • server/entity/MediaRequest.ts
  • server/entity/OverrideRule.ts
  • server/migration/postgres/1785245866761-AddCertificationToOverrideRules.ts
  • server/migration/sqlite/1785245659122-AddCertificationToOverrideRules.ts
  • server/routes/overrideRule.ts
  • src/components/Selector/CertificationSelector.tsx
  • src/components/Selector/index.tsx
  • src/components/Settings/OverrideRule/OverrideRuleModal.tsx
  • src/components/Settings/OverrideRule/OverrideRuleTiles.tsx
  • src/i18n/locale/en.json

Comment thread src/components/Settings/OverrideRule/OverrideRuleModal.tsx
Comment thread src/components/Settings/OverrideRule/OverrideRuleTiles.tsx
@aussierk
aussierk force-pushed the feature-add-certifications-to-override-rules branch from 2dea89d to a1256b7 Compare August 1, 2026 15:35
@aussierk
aussierk marked this pull request as draft August 1, 2026 15:46
@aussierk

aussierk commented Aug 1, 2026

Copy link
Copy Markdown
Author

Going to address these fixes and then figure out where I went wrong with the PR template.

@aussierk
aussierk marked this pull request as ready for review August 2, 2026 20:23
@aussierk

aussierk commented Aug 2, 2026

Copy link
Copy Markdown
Author

I have addressed the issues flagged by Code Rabbit to tighten up the code. I have also found the additional space that was causing the template validation to break. I am happy to continue reworking the override rules to address some of the other issues and to fix the rule ranking system in separate PRs.

@aussierk
aussierk force-pushed the feature-add-certifications-to-override-rules branch 4 times, most recently from dc358dd to 0103458 Compare August 11, 2026 14:00
… rules

Adds a certification condition to override rules, so admins can target requests by content
rating(e.g. US:PG-13) in addition to genre, language, and keywords. Country is pinned per entry
since TMDB certification codes aren't comparable across regions. This change only implements the
backend portion of the change and involves a database migration to add the certification field.]

feature seerr-team#301
Adds a flat multi-select certification picker to the override rule create/edit modal and its
list-view tiles, wired to the backend certification condition already in place. Modified a
previously unused CertificationSelector from the repo to match values and method expected in the
override rules certification condition.

feature seerr-team#301
… meaning display in ui

modified the ui for certification option in override rules to sort by country then maturity rating.
Moved meaning from display in-line to tool tip for better scrollability.

feature seerr-team#301
…d reset on service change

Adressed codeRabbit findings by adding a key to the overrideruletiles for certification and reset
the certification value if the service was changed while in the overriderule modal.

feature seerr-team#301
@aussierk
aussierk force-pushed the feature-add-certifications-to-override-rules branch from 0103458 to e3ea73c Compare August 16, 2026 13:45
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.

Radarr have different servers for different film ratings (pg, pg13, etc)

1 participant