diff options
| author | brandon <brandon@clinger.dev> | 2026-08-07 11:59:17 -0400 |
|---|---|---|
| committer | brandon <brandon@clinger.dev> | 2026-08-07 11:59:17 -0400 |
| commit | d6da6906a4b3426f05c5bf4ffe8bab4b2bc78ce8 (patch) | |
| tree | 78683665d1792916de8683b6ac5bc13e17904d87 /MediaBrowser.Controller/Persistence/IPeopleRepository.cs | |
| parent | 6c37a6ef8b4ce027e7ac2aaa827244711cf5f39c (diff) | |
Batch people lookups when building item DTOs
GetBaseItemDtos already batch fetches user data, child counts, played counts
and artists before its per item loop, but AttachPeople still ran one GetPeople
query per item. Rendering a page of items (for example a large playlist) fired
one extra query per row.
Add GetPeopleByItems to IPeopleRepository, which reads every requested item in a
single query over the people mapping table and returns full PersonInfo (role,
type and sort order) grouped by item id. GetBaseItemDtos prefetches this once
when the People field is requested and passes it into AttachPeople, which reads
from the batch instead of querying per item. The single item GetBaseItemDto path
keeps its existing per item behaviour when no batch is supplied.
Adds a DtoService test asserting people resolve from the batch and the per item
GetPeople is never called.
Diffstat (limited to 'MediaBrowser.Controller/Persistence/IPeopleRepository.cs')
| -rw-r--r-- | MediaBrowser.Controller/Persistence/IPeopleRepository.cs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/MediaBrowser.Controller/Persistence/IPeopleRepository.cs b/MediaBrowser.Controller/Persistence/IPeopleRepository.cs index e2833dc722..9811241d31 100644 --- a/MediaBrowser.Controller/Persistence/IPeopleRepository.cs +++ b/MediaBrowser.Controller/Persistence/IPeopleRepository.cs @@ -40,4 +40,11 @@ public interface IPeopleRepository /// <param name="personTypes">The person types to include (e.g. "Actor", "Director").</param> /// <returns>A dictionary mapping each item ID to its distinct people names, ordered by cast list order. Items with no matching people are omitted.</returns> IReadOnlyDictionary<Guid, IReadOnlyList<string>> GetPeopleNamesByItems(IReadOnlyList<Guid> itemIds, IReadOnlyList<string> personTypes); + + /// <summary> + /// Gets the people for multiple items in a single query, keyed by item id. + /// </summary> + /// <param name="itemIds">The item IDs to get people for.</param> + /// <returns>A dictionary mapping each item ID to its people (with role, type and sort order), ordered by cast list order. Items with no people are omitted.</returns> + IReadOnlyDictionary<Guid, IReadOnlyList<PersonInfo>> GetPeopleByItems(IReadOnlyList<Guid> itemIds); } |
