Skip to content

feat(rules): add rule Jellyfin favorited by including parents#2438

Merged
ydkmlt84 merged 4 commits into
Maintainerr:mainfrom
s1cstrings:favorited-incl-parents
Mar 9, 2026
Merged

feat(rules): add rule Jellyfin favorited by including parents#2438
ydkmlt84 merged 4 commits into
Maintainerr:mainfrom
s1cstrings:favorited-incl-parents

Conversation

@s1cstrings

Copy link
Copy Markdown
Contributor

Description & Design

This change adds a new Jellyfin rule for episodes/seasons: Favorited by (username) (incl. parents)

Problem solved:

  • The existing sw_favoritedBy rule only checks the current item. If media type is set to episode or season and the season or show (parent) is favorited, there is currently no way to check. This new rule allows checking for parents and is very useful when using this rule to prevent deletion of favorited media. For example, we don't want to delete episodes if a season is favorited.

Why this approach:

  • Keep existing rule behavior unchanged (sw_favoritedBy, id 40).
  • Add a separate rule (sw_favoritedBy_including_parent, id 41) so users can explicitly choose parent-inclusive behavior.

How it works:

  • Added new rule constant in rules.constants.ts for show types season and episode.
  • Added handling in JellyfinGetterService for sw_favoritedBy_including_parent.
  • New helper collects favorites from current item + parent + grandparent, deduplicates user IDs, then maps IDs to usernames.

Trade-offs / edge cases:

  • Performs up to 3 Jellyfin favorite lookups (item, parent, grandparent), so it is slightly more expensive than sw_favoritedBy.

AI-Assisted Development

I used Codex 5.3 to create the first draft and tests. I manually reviewed and edited the changes.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I understand the code I am submitting and can explain how it works
  • I have performed a self-review of my code
  • I have linted and formatted my code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

How to test

I added tests for the new rule sw_favoritedBy_including_parent as well as sw_favoritedBy since it didn't have tests already.

  1. Run unit tests for jellyfin getter logic:
    • yarn test -- apps/server/src/modules/rules/getter/jellyfin-getter.service.spec.ts
  2. Verify existing behavior:
    • Rule sw_favoritedBy (id 40) returns favorites from the current item only.
  3. Verify new behavior:
    • Rule sw_favoritedBy_including_parent (id 41) returns merged, deduplicated favorites from item + parent + grandparent.

@s1cstrings s1cstrings requested a review from ydkmlt84 as a code owner February 28, 2026 19:31
@enoch85

enoch85 commented Feb 28, 2026

Copy link
Copy Markdown
Collaborator

@s1cstrings Thanks for your PR!

Quick question, did you test the changes in prod?

@s1cstrings

s1cstrings commented Feb 28, 2026

Copy link
Copy Markdown
Contributor Author

@enoch85 I was in the process of setting up to run it in prod right now actually. I only tested in my test environment that mirrors my prod env but with test data. I will report back once up and running in prod.

@enoch85

enoch85 commented Feb 28, 2026

Copy link
Copy Markdown
Collaborator

Please add a PR to docs as well: https://github.com/Maintainerr/Maintainerr_docs

@s1cstrings

Copy link
Copy Markdown
Contributor Author

Please add a PR to docs as well: https://github.com/Maintainerr/Maintainerr_docs

my bad, i looked in the current repo for docs and then totally forgot to check where to add. will do shortly!

@enoch85

enoch85 commented Feb 28, 2026

Copy link
Copy Markdown
Collaborator

Not tested, but LGTM. 👍

@enoch85 enoch85 self-requested a review February 28, 2026 20:29
@s1cstrings

s1cstrings commented Feb 28, 2026

Copy link
Copy Markdown
Contributor Author

alright added pr for the docs. also used it in prod and it's working as it should. previously i was adding favorites to collections and using the collection incl parents rule to achieve similar result but it was causing issues for tv shows. with this favorite incl parent rule i don't have any issues anymore. yay!

enoch85 added a commit that referenced this pull request Mar 1, 2026
PR #2438 - feat(rules): add rule Jellyfin favorited by including parents
- Added Jellyfin favorited rule that checks parent items (series/seasons)
- Includes unit tests for the new favorited-by-parents getter

PR #2439 - fix: stop rule execution when rule group is deleted mid-run
- Changed onRuleGroupDeleted to call stopProcessingRuleGroup instead of removeFromQueue
- Fires abort signal for in-flight execution, preventing null reference crashes
- Added unit test for delete-during-execution scenario

PR #2442 - fix(server): reject null/undefined in numeric rule comparisons
- Fixed null guard using proper nullish check (`firstVal != null`)
- Preserves v2.27.0 null→0 coercion for BIGGER/SMALLER to avoid upgrade breakage
- Logs warning when non-number values are encountered in numeric comparisons
- Updated regression tests for numeric comparisons including null/undefined cases
@enoch85

enoch85 commented Mar 1, 2026

Copy link
Copy Markdown
Collaborator

This is now included in the jellyfin-dev docker container - among some other fixes. To upgrade, change tag in docker from latest (or whatever you have) to jellyfin-dev. Then do:

docker compose pull jellyfin-dev && docker compose up -d

You can check the latest commits here: https://github.com/Maintainerr/Maintainerr/commits/jellyfin-dev

  1. Consider the jellyfin-dev branch to be early development, and make a backup before switching to that branch!
  2. Please test that your issue is fixed
  3. Report back here, and tag me and @ydkmlt84

Thank you very much! 🚀

@ngregrichardson

Copy link
Copy Markdown

Amazing, was just about to make an issue for this! Jellyfin support has immediately made my stack so much more automated

@s1cstrings

Copy link
Copy Markdown
Contributor Author

@enoch85 @ydkmlt84 Thanks for including my PR so quickly to the dev branch!
I've been using it and tested extensively and everything is working just fine.
If someone has an issue or finds some edge case I haven't considered, don't hesitate to ping me and I will look into it.
As a bonus, it seems that another PR that was included (#2440) also fixed the issue i had with my collection rules.
Thanks for all the great work!

@ydkmlt84

ydkmlt84 commented Mar 9, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR!

@ydkmlt84 ydkmlt84 merged commit f9b66a4 into Maintainerr:main Mar 9, 2026
9 checks passed
@s1cstrings s1cstrings deleted the favorited-incl-parents branch March 9, 2026 23:28
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants