From beca405ad4c771f9cfdd5b410b4a4ba9f1c2d6c8 Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Mon, 11 Aug 2025 21:03:55 -0600 Subject: Refactor to pull item counts in a single query --- Emby.Server.Implementations/Library/LibraryManager.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'Emby.Server.Implementations/Library/LibraryManager.cs') diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index df71868b6..3aaaaba5a 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1389,6 +1389,25 @@ namespace Emby.Server.Implementations.Library return _itemRepository.GetCount(query); } + public ItemCounts GetItemCounts(InternalItemsQuery query) + { + if (query.Recursive && !query.ParentId.IsEmpty()) + { + var parent = GetItemById(query.ParentId); + if (parent is not null) + { + SetTopParentIdsOrAncestors(query, [parent]); + } + } + + if (query.User is not null) + { + AddUserToQuery(query, query.User); + } + + return _itemRepository.GetItemCounts(query); + } + public IReadOnlyList GetItemList(InternalItemsQuery query, List parents) { SetTopParentIdsOrAncestors(query, parents); -- cgit v1.2.3