Refactor to pull item counts in a single query

This commit is contained in:
Cody Robibero
2025-08-11 21:03:55 -06:00
parent 5eef85f027
commit beca405ad4
14 changed files with 207 additions and 233 deletions
-42
View File
@@ -6,7 +6,6 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text.Json.Serialization;
using Jellyfin.Data.Enums;
using Microsoft.Extensions.Logging;
namespace MediaBrowser.Controller.Entities
@@ -69,47 +68,6 @@ namespace MediaBrowser.Controller.Entities
return LibraryManager.GetItemList(query);
}
public TaggedItemCounts GetTaggedItemCounts(InternalItemsQuery query)
{
if (!int.TryParse(Name, NumberStyles.Integer, CultureInfo.InvariantCulture, out var year))
{
return new TaggedItemCounts();
}
query.Years = [year];
var counts = new TaggedItemCounts();
query.IncludeItemTypes = [BaseItemKind.MusicAlbum];
counts.AlbumCount = LibraryManager.GetCount(query);
query.IncludeItemTypes = [BaseItemKind.MusicArtist];
counts.ArtistCount = LibraryManager.GetCount(query);
query.IncludeItemTypes = [BaseItemKind.Episode];
counts.EpisodeCount = LibraryManager.GetCount(query);
query.IncludeItemTypes = [BaseItemKind.Movie];
counts.MovieCount = LibraryManager.GetCount(query);
query.IncludeItemTypes = [BaseItemKind.MusicVideo];
counts.MusicVideoCount = LibraryManager.GetCount(query);
query.IncludeItemTypes = [BaseItemKind.LiveTvProgram];
counts.ProgramCount = LibraryManager.GetCount(query);
query.IncludeItemTypes = [BaseItemKind.Series];
counts.SeriesCount = LibraryManager.GetCount(query);
query.IncludeItemTypes = [BaseItemKind.Audio];
counts.SongCount = LibraryManager.GetCount(query);
query.IncludeItemTypes = [BaseItemKind.Trailer];
counts.TrailerCount = LibraryManager.GetCount(query);
return counts;
}
public int? GetYearValue()
{
if (int.TryParse(Name, NumberStyles.Integer, CultureInfo.InvariantCulture, out var year))