Merge pull request #17576 from obiwantoby/perf/batch-mediasourcecount-dto

Bugfix: #17547 | Batching MediaSourceCount into one call
This commit is contained in:
Cody Robibero
2026-08-10 16:15:54 -04:00
committed by GitHub
6 changed files with 164 additions and 12 deletions
@@ -59,6 +59,25 @@ public class LinkedChildrenService : ILinkedChildrenService
.ToArray();
}
/// <inheritdoc/>
public IReadOnlySet<Guid> GetItemIdsWithAlternateVersions(IReadOnlyList<Guid> itemIds)
{
if (itemIds.Count == 0)
{
return new HashSet<Guid>();
}
using var dbContext = _dbProvider.CreateDbContext();
return dbContext.LinkedChildren
.Where(lc => lc.ChildType == DbLinkedChildType.LocalAlternateVersion
|| lc.ChildType == DbLinkedChildType.LinkedAlternateVersion)
.WhereOneOrMany(itemIds as IList<Guid> ?? itemIds.ToList(), lc => lc.ParentId)
.Select(lc => lc.ParentId)
.Distinct()
.ToHashSet();
}
/// <inheritdoc/>
public IReadOnlyDictionary<string, MusicArtist[]> FindArtists(IReadOnlyList<string> artistNames)
{