mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-02 05:48:47 +01:00
improved performance of item counts
This commit is contained in:
@@ -108,7 +108,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
}
|
||||
|
||||
// Populate counts of items
|
||||
SetItemCounts(artist, null, allItems.OfType<IHasArtist>());
|
||||
//SetItemCounts(artist, null, allItems.OfType<IHasArtist>());
|
||||
|
||||
foreach (var lib in userLibraries)
|
||||
{
|
||||
@@ -155,10 +155,6 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
{
|
||||
artist.UserItemCounts[userId.Value] = counts;
|
||||
}
|
||||
else
|
||||
{
|
||||
artist.ItemCounts = counts;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -18,46 +18,46 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="counts">The counts.</param>
|
||||
internal static void AddToDictionary(BaseItem item, Dictionary<string, int> counts)
|
||||
internal static void AddToDictionary(BaseItem item, Dictionary<CountType, int> counts)
|
||||
{
|
||||
if (item is Movie)
|
||||
{
|
||||
IncrementCount(counts, "Movie");
|
||||
IncrementCount(counts, CountType.Movie);
|
||||
}
|
||||
else if (item is Trailer)
|
||||
{
|
||||
IncrementCount(counts, "Trailer");
|
||||
IncrementCount(counts, CountType.Trailer);
|
||||
}
|
||||
else if (item is Series)
|
||||
{
|
||||
IncrementCount(counts, "Series");
|
||||
IncrementCount(counts, CountType.Series);
|
||||
}
|
||||
else if (item is Game)
|
||||
{
|
||||
IncrementCount(counts, "Game");
|
||||
IncrementCount(counts, CountType.Game);
|
||||
}
|
||||
else if (item is Audio)
|
||||
{
|
||||
IncrementCount(counts, "Audio");
|
||||
IncrementCount(counts, CountType.Song);
|
||||
}
|
||||
else if (item is MusicAlbum)
|
||||
{
|
||||
IncrementCount(counts, "MusicAlbum");
|
||||
IncrementCount(counts, CountType.MusicAlbum);
|
||||
}
|
||||
else if (item is Episode)
|
||||
{
|
||||
IncrementCount(counts, "Episode");
|
||||
IncrementCount(counts, CountType.Episode);
|
||||
}
|
||||
else if (item is MusicVideo)
|
||||
{
|
||||
IncrementCount(counts, "MusicVideo");
|
||||
IncrementCount(counts, CountType.MusicVideo);
|
||||
}
|
||||
else if (item is AdultVideo)
|
||||
{
|
||||
IncrementCount(counts, "AdultVideo");
|
||||
IncrementCount(counts, CountType.AdultVideo);
|
||||
}
|
||||
|
||||
IncrementCount(counts, "Total");
|
||||
IncrementCount(counts, CountType.Total);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -65,7 +65,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
/// </summary>
|
||||
/// <param name="counts">The counts.</param>
|
||||
/// <param name="key">The key.</param>
|
||||
internal static void IncrementCount(Dictionary<string, int> counts, string key)
|
||||
internal static void IncrementCount(Dictionary<CountType, int> counts, CountType key)
|
||||
{
|
||||
int count;
|
||||
|
||||
@@ -85,20 +85,20 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
/// </summary>
|
||||
/// <param name="counts">The counts.</param>
|
||||
/// <returns>ItemByNameCounts.</returns>
|
||||
internal static ItemByNameCounts GetCounts(Dictionary<string, int> counts)
|
||||
internal static ItemByNameCounts GetCounts(Dictionary<CountType, int> counts)
|
||||
{
|
||||
return new ItemByNameCounts
|
||||
{
|
||||
AdultVideoCount = GetCount(counts, "AdultVideo"),
|
||||
AlbumCount = GetCount(counts, "MusicAlbum"),
|
||||
EpisodeCount = GetCount(counts, "Episode"),
|
||||
GameCount = GetCount(counts, "Game"),
|
||||
MovieCount = GetCount(counts, "Movie"),
|
||||
MusicVideoCount = GetCount(counts, "MusicVideo"),
|
||||
SeriesCount = GetCount(counts, "Series"),
|
||||
SongCount = GetCount(counts, "Audio"),
|
||||
TrailerCount = GetCount(counts, "Trailer"),
|
||||
TotalCount = GetCount(counts, "Total")
|
||||
AdultVideoCount = GetCount(counts, CountType.AdultVideo),
|
||||
AlbumCount = GetCount(counts, CountType.MusicAlbum),
|
||||
EpisodeCount = GetCount(counts, CountType.Episode),
|
||||
GameCount = GetCount(counts, CountType.Game),
|
||||
MovieCount = GetCount(counts, CountType.Movie),
|
||||
MusicVideoCount = GetCount(counts, CountType.MusicVideo),
|
||||
SeriesCount = GetCount(counts, CountType.Series),
|
||||
SongCount = GetCount(counts, CountType.Song),
|
||||
TrailerCount = GetCount(counts, CountType.Trailer),
|
||||
TotalCount = GetCount(counts, CountType.Total)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
/// <param name="counts">The counts.</param>
|
||||
/// <param name="key">The key.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
internal static int GetCount(Dictionary<string, int> counts, string key)
|
||||
internal static int GetCount(Dictionary<CountType, int> counts, CountType key)
|
||||
{
|
||||
int count;
|
||||
|
||||
@@ -127,24 +127,24 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
/// <param name="media">The media.</param>
|
||||
/// <param name="names">The names.</param>
|
||||
/// <param name="masterDictionary">The master dictionary.</param>
|
||||
internal static void SetItemCounts(Guid? userId, BaseItem media, List<string> names, Dictionary<string, Dictionary<Guid, Dictionary<string, int>>> masterDictionary)
|
||||
internal static void SetItemCounts(Guid userId, BaseItem media, List<string> names, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
||||
{
|
||||
foreach (var name in names)
|
||||
{
|
||||
Dictionary<Guid, Dictionary<string, int>> libraryCounts;
|
||||
Dictionary<Guid, Dictionary<CountType, int>> libraryCounts;
|
||||
|
||||
if (!masterDictionary.TryGetValue(name, out libraryCounts))
|
||||
{
|
||||
libraryCounts = new Dictionary<Guid, Dictionary<string, int>>();
|
||||
libraryCounts = new Dictionary<Guid, Dictionary<CountType, int>>();
|
||||
masterDictionary.Add(name, libraryCounts);
|
||||
}
|
||||
|
||||
var userLibId = userId ?? Guid.Empty;
|
||||
Dictionary<string, int> userDictionary;
|
||||
var userLibId = userId/* ?? Guid.Empty*/;
|
||||
Dictionary<CountType, int> userDictionary;
|
||||
|
||||
if (!libraryCounts.TryGetValue(userLibId, out userDictionary))
|
||||
{
|
||||
userDictionary = new Dictionary<string, int>();
|
||||
userDictionary = new Dictionary<CountType, int>();
|
||||
libraryCounts.Add(userLibId, userDictionary);
|
||||
}
|
||||
|
||||
@@ -152,4 +152,18 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal enum CountType
|
||||
{
|
||||
AdultVideo,
|
||||
MusicAlbum,
|
||||
Episode,
|
||||
Game,
|
||||
Movie,
|
||||
MusicVideo,
|
||||
Series,
|
||||
Song,
|
||||
Trailer,
|
||||
Total
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,10 +49,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
var allLibraryItems = allItems;
|
||||
|
||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<string, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
// Populate counts of items
|
||||
SetItemCounts(null, allLibraryItems, masterDictionary);
|
||||
//SetItemCounts(null, allLibraryItems, masterDictionary);
|
||||
|
||||
progress.Report(2);
|
||||
|
||||
@@ -72,10 +72,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
progress.Report(10);
|
||||
|
||||
var names = masterDictionary.Keys.ToList();
|
||||
var count = masterDictionary.Count;
|
||||
numComplete = 0;
|
||||
|
||||
foreach (var name in names)
|
||||
foreach (var name in masterDictionary.Keys)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -88,7 +88,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= names.Count;
|
||||
percent /= count;
|
||||
percent *= 90;
|
||||
|
||||
progress.Report(percent + 10);
|
||||
@@ -97,26 +97,19 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<string, int>> counts)
|
||||
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
|
||||
{
|
||||
var itemByName = await _libraryManager.GetGameGenre(name, cancellationToken, true, true).ConfigureAwait(false);
|
||||
|
||||
foreach (var libraryId in counts.Keys.ToList())
|
||||
foreach (var libraryId in counts.Keys)
|
||||
{
|
||||
var itemCounts = CountHelpers.GetCounts(counts[libraryId]);
|
||||
|
||||
if (libraryId == Guid.Empty)
|
||||
{
|
||||
itemByName.ItemCounts = itemCounts;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||
}
|
||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetItemCounts(Guid? userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<string, int>>> masterDictionary)
|
||||
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
||||
{
|
||||
foreach (var media in allItems)
|
||||
{
|
||||
|
||||
@@ -52,10 +52,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
var allLibraryItems = allItems;
|
||||
|
||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<string, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
// Populate counts of items
|
||||
SetItemCounts(null, allLibraryItems, masterDictionary);
|
||||
//SetItemCounts(null, allLibraryItems, masterDictionary);
|
||||
|
||||
progress.Report(2);
|
||||
|
||||
@@ -75,10 +75,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
progress.Report(10);
|
||||
|
||||
var names = masterDictionary.Keys.ToList();
|
||||
var count = masterDictionary.Count;
|
||||
numComplete = 0;
|
||||
|
||||
foreach (var name in names)
|
||||
foreach (var name in masterDictionary.Keys)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -91,7 +91,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= names.Count;
|
||||
percent /= count;
|
||||
percent *= 90;
|
||||
|
||||
progress.Report(percent + 10);
|
||||
@@ -100,26 +100,19 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<string, int>> counts)
|
||||
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
|
||||
{
|
||||
var itemByName = await _libraryManager.GetGenre(name, cancellationToken, true, true).ConfigureAwait(false);
|
||||
|
||||
foreach (var libraryId in counts.Keys.ToList())
|
||||
foreach (var libraryId in counts.Keys)
|
||||
{
|
||||
var itemCounts = CountHelpers.GetCounts(counts[libraryId]);
|
||||
|
||||
if (libraryId == Guid.Empty)
|
||||
{
|
||||
itemByName.ItemCounts = itemCounts;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||
}
|
||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetItemCounts(Guid? userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<string, int>>> masterDictionary)
|
||||
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
||||
{
|
||||
foreach (var media in allItems)
|
||||
{
|
||||
|
||||
@@ -52,10 +52,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
var allLibraryItems = allItems;
|
||||
|
||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<string, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
// Populate counts of items
|
||||
SetItemCounts(null, allLibraryItems, masterDictionary);
|
||||
//SetItemCounts(null, allLibraryItems, masterDictionary);
|
||||
|
||||
progress.Report(2);
|
||||
|
||||
@@ -75,10 +75,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
progress.Report(10);
|
||||
|
||||
var names = masterDictionary.Keys.ToList();
|
||||
var count = masterDictionary.Count;
|
||||
numComplete = 0;
|
||||
|
||||
foreach (var name in names)
|
||||
foreach (var name in masterDictionary.Keys)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -91,7 +91,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= names.Count;
|
||||
percent /= count;
|
||||
percent *= 90;
|
||||
|
||||
progress.Report(percent + 10);
|
||||
@@ -100,26 +100,19 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<string, int>> counts)
|
||||
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
|
||||
{
|
||||
var itemByName = await _libraryManager.GetMusicGenre(name, cancellationToken, true, true).ConfigureAwait(false);
|
||||
|
||||
foreach (var libraryId in counts.Keys.ToList())
|
||||
foreach (var libraryId in counts.Keys)
|
||||
{
|
||||
var itemCounts = CountHelpers.GetCounts(counts[libraryId]);
|
||||
|
||||
if (libraryId == Guid.Empty)
|
||||
{
|
||||
itemByName.ItemCounts = itemCounts;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||
}
|
||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetItemCounts(Guid? userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<string, int>>> masterDictionary)
|
||||
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
||||
{
|
||||
foreach (var media in allItems)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,13 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
/// <param name="progress">The progress.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
public async Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
public Task Run(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
return RunInternal(progress, cancellationToken);
|
||||
//return Task.Run(() => RunInternal(progress, cancellationToken));
|
||||
}
|
||||
|
||||
private async Task RunInternal(IProgress<double> progress, CancellationToken cancellationToken)
|
||||
{
|
||||
var allItems = _libraryManager.RootFolder.RecursiveChildren.ToList();
|
||||
|
||||
@@ -49,10 +55,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
var allLibraryItems = allItems;
|
||||
|
||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<string, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
// Populate counts of items
|
||||
SetItemCounts(null, allLibraryItems, masterDictionary);
|
||||
//SetItemCounts(null, allLibraryItems, masterDictionary);
|
||||
|
||||
progress.Report(2);
|
||||
|
||||
@@ -74,16 +80,25 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
progress.Report(10);
|
||||
|
||||
var names = masterDictionary.Keys.ToList();
|
||||
var count = masterDictionary.Count;
|
||||
numComplete = 0;
|
||||
|
||||
foreach (var name in names)
|
||||
foreach (var name in masterDictionary.Keys)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
await UpdateItemByNameCounts(name, masterDictionary[name]).ConfigureAwait(false);
|
||||
var counts = masterDictionary[name];
|
||||
|
||||
var itemByName = await _libraryManager.GetPerson(name).ConfigureAwait(false);
|
||||
|
||||
foreach (var libraryId in counts.Keys)
|
||||
{
|
||||
var itemCounts = CountHelpers.GetCounts(counts[libraryId]);
|
||||
|
||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -92,7 +107,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= names.Count;
|
||||
percent /= count;
|
||||
percent *= 90;
|
||||
|
||||
progress.Report(percent + 10);
|
||||
@@ -101,26 +116,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
private async Task UpdateItemByNameCounts(string name, Dictionary<Guid, Dictionary<string, int>> counts)
|
||||
{
|
||||
var itemByName = await _libraryManager.GetPerson(name).ConfigureAwait(false);
|
||||
|
||||
foreach (var libraryId in counts.Keys.ToList())
|
||||
{
|
||||
var itemCounts = CountHelpers.GetCounts(counts[libraryId]);
|
||||
|
||||
if (libraryId == Guid.Empty)
|
||||
{
|
||||
itemByName.ItemCounts = itemCounts;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SetItemCounts(Guid? userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<string, int>>> masterDictionary)
|
||||
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
||||
{
|
||||
foreach (var media in allItems)
|
||||
{
|
||||
|
||||
@@ -49,10 +49,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
var allLibraryItems = allItems;
|
||||
|
||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<string, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||
var masterDictionary = new Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
// Populate counts of items
|
||||
SetItemCounts(null, allLibraryItems, masterDictionary);
|
||||
//SetItemCounts(null, allLibraryItems, masterDictionary);
|
||||
|
||||
progress.Report(2);
|
||||
|
||||
@@ -72,10 +72,10 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
progress.Report(10);
|
||||
|
||||
var names = masterDictionary.Keys.ToList();
|
||||
var count = masterDictionary.Count;
|
||||
numComplete = 0;
|
||||
|
||||
foreach (var name in names)
|
||||
foreach (var name in masterDictionary.Keys)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -88,7 +88,7 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
|
||||
numComplete++;
|
||||
double percent = numComplete;
|
||||
percent /= names.Count;
|
||||
percent /= count;
|
||||
percent *= 90;
|
||||
|
||||
progress.Report(percent + 10);
|
||||
@@ -97,26 +97,19 @@ namespace MediaBrowser.Server.Implementations.Library.Validators
|
||||
progress.Report(100);
|
||||
}
|
||||
|
||||
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<string, int>> counts)
|
||||
private async Task UpdateItemByNameCounts(string name, CancellationToken cancellationToken, Dictionary<Guid, Dictionary<CountType, int>> counts)
|
||||
{
|
||||
var itemByName = await _libraryManager.GetStudio(name, cancellationToken, true, true).ConfigureAwait(false);
|
||||
|
||||
foreach (var libraryId in counts.Keys.ToList())
|
||||
foreach (var libraryId in counts.Keys)
|
||||
{
|
||||
var itemCounts = CountHelpers.GetCounts(counts[libraryId]);
|
||||
|
||||
if (libraryId == Guid.Empty)
|
||||
{
|
||||
itemByName.ItemCounts = itemCounts;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||
}
|
||||
itemByName.UserItemCounts[libraryId] = itemCounts;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetItemCounts(Guid? userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<string, int>>> masterDictionary)
|
||||
private void SetItemCounts(Guid userId, IEnumerable<BaseItem> allItems, Dictionary<string, Dictionary<Guid, Dictionary<CountType, int>>> masterDictionary)
|
||||
{
|
||||
foreach (var media in allItems)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user