mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-25 11:34:43 +01:00
update season queries
This commit is contained in:
@@ -955,20 +955,23 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
dto.Genres = item.Genres;
|
||||
}
|
||||
|
||||
dto.ImageTags = new Dictionary<ImageType, string>();
|
||||
|
||||
// Prevent implicitly captured closure
|
||||
var currentItem = item;
|
||||
foreach (var image in currentItem.ImageInfos.Where(i => !currentItem.AllowsMultipleImages(i.Type))
|
||||
.ToList())
|
||||
if (options.EnableImages)
|
||||
{
|
||||
if (options.GetImageLimit(image.Type) > 0)
|
||||
{
|
||||
var tag = GetImageCacheTag(item, image);
|
||||
dto.ImageTags = new Dictionary<ImageType, string>();
|
||||
|
||||
if (tag != null)
|
||||
// Prevent implicitly captured closure
|
||||
var currentItem = item;
|
||||
foreach (var image in currentItem.ImageInfos.Where(i => !currentItem.AllowsMultipleImages(i.Type))
|
||||
.ToList())
|
||||
{
|
||||
if (options.GetImageLimit(image.Type) > 0)
|
||||
{
|
||||
dto.ImageTags[image.Type] = tag;
|
||||
var tag = GetImageCacheTag(item, image);
|
||||
|
||||
if (tag != null)
|
||||
{
|
||||
dto.ImageTags[image.Type] = tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1527,97 +1530,6 @@ namespace MediaBrowser.Server.Implementations.Dto
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Since it can be slow to make all of these calculations independently, this method will provide a way to do them all at once
|
||||
/// </summary>
|
||||
/// <param name="folder">The folder.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <param name="dto">The dto.</param>
|
||||
/// <param name="fields">The fields.</param>
|
||||
/// <param name="syncProgress">The synchronize progress.</param>
|
||||
/// <returns>Task.</returns>
|
||||
private async Task SetSpecialCounts(Folder folder, User user, BaseItemDto dto, List<ItemFields> fields, Dictionary<string, SyncJobItemStatus> syncProgress)
|
||||
{
|
||||
var recursiveItemCount = 0;
|
||||
var unplayed = 0;
|
||||
|
||||
double totalPercentPlayed = 0;
|
||||
double totalSyncPercent = 0;
|
||||
|
||||
var children = await folder.GetItems(new InternalItemsQuery
|
||||
{
|
||||
IsFolder = false,
|
||||
Recursive = true,
|
||||
ExcludeLocationTypes = new[] { LocationType.Virtual },
|
||||
User = user
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
// Loop through each recursive child
|
||||
foreach (var child in children.Items)
|
||||
{
|
||||
var userdata = _userDataRepository.GetUserData(user, child);
|
||||
|
||||
recursiveItemCount++;
|
||||
|
||||
var isUnplayed = true;
|
||||
|
||||
// Incrememt totalPercentPlayed
|
||||
if (userdata != null)
|
||||
{
|
||||
if (userdata.Played)
|
||||
{
|
||||
totalPercentPlayed += 100;
|
||||
|
||||
isUnplayed = false;
|
||||
}
|
||||
else if (userdata.PlaybackPositionTicks > 0 && child.RunTimeTicks.HasValue && child.RunTimeTicks.Value > 0)
|
||||
{
|
||||
double itemPercent = userdata.PlaybackPositionTicks;
|
||||
itemPercent /= child.RunTimeTicks.Value;
|
||||
totalPercentPlayed += itemPercent;
|
||||
}
|
||||
}
|
||||
|
||||
if (isUnplayed)
|
||||
{
|
||||
unplayed++;
|
||||
}
|
||||
|
||||
double percent = 0;
|
||||
SyncJobItemStatus syncItemProgress;
|
||||
if (syncProgress.TryGetValue(child.Id.ToString("N"), out syncItemProgress))
|
||||
{
|
||||
switch (syncItemProgress)
|
||||
{
|
||||
case SyncJobItemStatus.Synced:
|
||||
percent = 100;
|
||||
break;
|
||||
case SyncJobItemStatus.Converting:
|
||||
case SyncJobItemStatus.ReadyToTransfer:
|
||||
case SyncJobItemStatus.Transferring:
|
||||
percent = 50;
|
||||
break;
|
||||
}
|
||||
}
|
||||
totalSyncPercent += percent;
|
||||
}
|
||||
|
||||
dto.RecursiveItemCount = recursiveItemCount;
|
||||
dto.UserData.UnplayedItemCount = unplayed;
|
||||
|
||||
if (recursiveItemCount > 0)
|
||||
{
|
||||
dto.UserData.PlayedPercentage = totalPercentPlayed / recursiveItemCount;
|
||||
|
||||
var pct = totalSyncPercent / recursiveItemCount;
|
||||
if (pct > 0)
|
||||
{
|
||||
dto.SyncPercent = pct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches the primary image aspect ratio.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user