fix: use ParentId per library instead of TopParentIds for mediabar - #51
Merged
RadicalMuffinMan merged 2 commits intoMar 15, 2026
Conversation
TopParentIds filters on an internal DB column whose values differ from the user-facing view GUIDs returned by getUserViews(). This caused 0 results when specific libraries were selected. Switch to per-library queries using ParentId (which matches view IDs), each with OrderBy=Random and Limit for efficient DB-level random selection without loading entire libraries into memory. Also sets OrderBy=Random via reflection to avoid compile-time reference to SortOrder which moved assemblies between 10.10 and 10.11.
TopParentIds filters on an internal DB column whose values differ from the user-facing view GUIDs returned by getUserViews(). This caused 0 results when specific libraries were selected. Switch to per-library queries using ParentId (which matches view IDs), each with OrderBy=Random and Limit for efficient DB-level random selection without loading entire libraries into memory. Also sets OrderBy=Random via reflection to avoid compile-time reference to SortOrder which moved assemblies between 10.10 and 10.11.
✅ Build SuccessfulThe plugin compiled successfully against .NET 8 / Jellyfin 10.10.0.
|
| // whose values differ from the user-facing view GUIDs. | ||
| var allItems = new List<BaseItem>(); | ||
| var seenIds = new HashSet<Guid>(); | ||
| var perLibraryLimit = Math.Max(1, limit / libraryIds.Count + 1); |
There was a problem hiding this comment.
kinda late, sorry, but is per library fairness really what you want?
example:
Library1 - 1000
Library2 - 250
Library3 - 20
Library4 - 10
Library5 - 5
Ideally Library1 should be represented the most. Right now you would have a lot of repeats from small libraries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found another bug when selecting specific libraries, introduced by the
TopParentIdsusage.The fix queries each selected library individually via
ParentId, withOrderBy=Random+Limitat the DB level. Results are merged, shuffled for fair representation across libraries, then trimmed to the requested limit. At mostlimit + selectedLibraryCountitems are held in memory (e.g. 13 items for limit=10 with 3 libraries).This fixes the issue in my local testing.