From 077fa89717957f871b172ca4b2dc4a178efd3bc5 Mon Sep 17 00:00:00 2001 From: Shadowghost Date: Sat, 7 Mar 2026 20:12:42 +0100 Subject: Split BaseItemRepository and IItemRepository --- .../Persistence/IItemCountService.cs | 86 ++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 MediaBrowser.Controller/Persistence/IItemCountService.cs (limited to 'MediaBrowser.Controller/Persistence/IItemCountService.cs') diff --git a/MediaBrowser.Controller/Persistence/IItemCountService.cs b/MediaBrowser.Controller/Persistence/IItemCountService.cs new file mode 100644 index 0000000000..d57f1fc893 --- /dev/null +++ b/MediaBrowser.Controller/Persistence/IItemCountService.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using Jellyfin.Data.Enums; +using Jellyfin.Database.Implementations.Entities; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Dto; + +namespace MediaBrowser.Controller.Persistence; + +/// +/// Provides item counting and played-status query operations. +/// +public interface IItemCountService +{ + /// + /// Gets the count of items matching the filter. + /// + /// The query filter. + /// The item count. + int GetCount(InternalItemsQuery filter); + + /// + /// Gets item counts grouped by type. + /// + /// The query filter. + /// The item counts by type. + ItemCounts GetItemCounts(InternalItemsQuery filter); + + /// + /// Gets item counts for a "by-name" item using an optimized query. + /// + /// The kind of the name item. + /// The ID of the name item. + /// The item kinds to count. + /// A pre-configured query with user access filtering settings. + /// The item counts grouped by type. + ItemCounts GetItemCountsForNameItem(BaseItemKind kind, Guid id, BaseItemKind[] relatedItemKinds, InternalItemsQuery accessFilter); + + /// + /// Gets the count of played items that are descendants of the specified ancestor. + /// + /// The query filter containing user access settings. + /// The ancestor item id. + /// The count of played descendant items. + int GetPlayedCount(InternalItemsQuery filter, Guid ancestorId); + + /// + /// Gets the total count of items that are descendants of the specified ancestor. + /// + /// The query filter containing user access settings. + /// The ancestor item id. + /// The total count of descendant items. + int GetTotalCount(InternalItemsQuery filter, Guid ancestorId); + + /// + /// Gets both the played count and total count of descendant items. + /// + /// The query filter containing user access settings. + /// The ancestor item id. + /// A tuple containing (Played count, Total count). + (int Played, int Total) GetPlayedAndTotalCount(InternalItemsQuery filter, Guid ancestorId); + + /// + /// Gets both the played count and total count from linked children. + /// + /// The query filter containing user access settings. + /// The parent item id. + /// A tuple containing (Played count, Total count). + (int Played, int Total) GetPlayedAndTotalCountFromLinkedChildren(InternalItemsQuery filter, Guid parentId); + + /// + /// Batch-fetches played and total counts for multiple folder items. + /// + /// The list of folder item IDs to get counts for. + /// The user for access filtering and played status. + /// Dictionary mapping folder ID to (Played count, Total count). + Dictionary GetPlayedAndTotalCountBatch(IReadOnlyList folderIds, User user); + + /// + /// Batch-fetches child counts for multiple parent folders. + /// + /// The list of parent folder IDs. + /// The user ID for access filtering. + /// Dictionary mapping parent ID to child count. + Dictionary GetChildCountBatch(IReadOnlyList parentIds, Guid? userId); +} -- cgit v1.2.3