mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-13 08:37:07 +00:00
Fix review comments
This commit is contained in:
parent
2365cea626
commit
0d58c773f9
3 changed files with 7 additions and 7 deletions
|
|
@ -205,7 +205,7 @@ namespace Emby.Server.Implementations.Dto
|
|||
|
||||
// Batch-fetch MusicArtist lookups across all items to avoid N+1 queries.
|
||||
IReadOnlyDictionary<string, MusicArtist[]>? artistsBatch = null;
|
||||
HashSet<string>? artistNames = null;
|
||||
var artistNames = new HashSet<string>(StringComparer.Ordinal);
|
||||
foreach (var item in accessibleItems)
|
||||
{
|
||||
if (item is IHasArtist hasArtist)
|
||||
|
|
@ -214,7 +214,7 @@ namespace Emby.Server.Implementations.Dto
|
|||
{
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
(artistNames ??= new HashSet<string>(StringComparer.Ordinal)).Add(name);
|
||||
artistNames.Add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -225,13 +225,13 @@ namespace Emby.Server.Implementations.Dto
|
|||
{
|
||||
if (!string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
(artistNames ??= new HashSet<string>(StringComparer.Ordinal)).Add(name);
|
||||
artistNames.Add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (artistNames is { Count: > 0 })
|
||||
if (artistNames.Count > 0)
|
||||
{
|
||||
artistsBatch = _libraryManager.GetArtists(artistNames.ToArray());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,13 +145,11 @@ public sealed partial class BaseItemRepository
|
|||
}
|
||||
|
||||
// Albums whose Id is the parent of any track matching the user's filter.
|
||||
var musicAlbumType = _itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicAlbum]!;
|
||||
|
||||
var albumIdsWithMatchingTrack = context.AncestorIds
|
||||
.Join(baseQuery, ai => ai.ItemId, t => t.Id, (ai, _) => ai.ParentItemId);
|
||||
|
||||
var topAlbumsQuery = context.BaseItems.AsNoTracking()
|
||||
.Where(album => album.Type == musicAlbumType)
|
||||
.Where(album => album.Type == _musicAlbumTypeName)
|
||||
.Where(album => albumIdsWithMatchingTrack.Contains(album.Id))
|
||||
.OrderByDescending(album => album.DateCreated)
|
||||
.ThenByDescending(album => album.Id);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public sealed partial class BaseItemRepository
|
|||
private readonly IItemTypeLookup _itemTypeLookup;
|
||||
private readonly IServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly ILogger<BaseItemRepository> _logger;
|
||||
private readonly string _musicAlbumTypeName;
|
||||
|
||||
private static readonly IReadOnlyList<ItemValueType> _getAllArtistsValueTypes = [ItemValueType.Artist, ItemValueType.AlbumArtist];
|
||||
private static readonly IReadOnlyList<ItemValueType> _getArtistValueTypes = [ItemValueType.Artist];
|
||||
|
|
@ -66,6 +67,7 @@ public sealed partial class BaseItemRepository
|
|||
_itemTypeLookup = itemTypeLookup;
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
_logger = logger;
|
||||
_musicAlbumTypeName = itemTypeLookup.BaseItemKindNames[BaseItemKind.MusicAlbum]!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue