Fix review comments

This commit is contained in:
Shadowghost
2026-03-05 22:54:26 +01:00
parent f5b2e0b8f9
commit 744c5539d8
2 changed files with 152 additions and 157 deletions

View File

@@ -49,6 +49,33 @@ public static class DescendantQueryHelper
return descendants.AsQueryable();
}
/// <summary>
/// Gets all owned descendant IDs for multiple parent items in a single traversal.
/// More efficient than calling <see cref="GetOwnedDescendantIds"/> per parent because
/// it performs one traversal for all seeds instead of N separate traversals.
/// </summary>
/// <param name="context">Database context.</param>
/// <param name="parentIds">Parent item IDs.</param>
/// <returns>Set of all owned descendant item IDs (excluding the parent IDs themselves).</returns>
public static HashSet<Guid> GetOwnedDescendantIdsBatch(JellyfinDbContext context, IReadOnlyList<Guid> parentIds)
{
ArgumentNullException.ThrowIfNull(context);
ArgumentNullException.ThrowIfNull(parentIds);
if (parentIds.Count == 0)
{
return [];
}
var seedSet = new HashSet<Guid>(parentIds);
var descendants = TraverseHierarchyDownOwned(context, seedSet);
// Remove the seed IDs — callers want only descendants
descendants.ExceptWith(seedSet);
return descendants;
}
/// <summary>
/// Gets a queryable of all folder IDs that have any descendant matching the specified criteria.
/// Can be used in LINQ .Contains() expressions.