1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-22 07:43:01 +00:00

Rename SizeLeft and TimeLeft queue item properties

Closes #7392
This commit is contained in:
Mark McDowall 2024-11-18 16:50:56 -08:00
parent 8b38ccfb63
commit b51a490979
5 changed files with 31 additions and 21 deletions

View file

@ -359,11 +359,11 @@ namespace NzbDrone.Core.Download.Pending
ect = ect.AddMinutes(_configService.RssSyncInterval);
}
var timeleft = ect.Subtract(DateTime.UtcNow);
var timeLeft = ect.Subtract(DateTime.UtcNow);
if (timeleft.TotalSeconds < 0)
if (timeLeft.TotalSeconds < 0)
{
timeleft = TimeSpan.Zero;
timeLeft = TimeSpan.Zero;
}
string downloadClientName = null;
@ -385,9 +385,9 @@ namespace NzbDrone.Core.Download.Pending
Quality = pendingRelease.RemoteEpisode.ParsedEpisodeInfo.Quality,
Title = pendingRelease.Title,
Size = pendingRelease.RemoteEpisode.Release.Size,
Sizeleft = pendingRelease.RemoteEpisode.Release.Size,
SizeLeft = pendingRelease.RemoteEpisode.Release.Size,
RemoteEpisode = pendingRelease.RemoteEpisode,
Timeleft = timeleft,
TimeLeft = timeLeft,
EstimatedCompletionTime = ect,
Added = pendingRelease.Added,
Status = Enum.TryParse(pendingRelease.Reason.ToString(), out QueueStatus outValue) ? outValue : QueueStatus.Unknown,

View file

@ -18,8 +18,8 @@ namespace NzbDrone.Core.Queue
public QualityModel Quality { get; set; }
public decimal Size { get; set; }
public string Title { get; set; }
public decimal Sizeleft { get; set; }
public TimeSpan? Timeleft { get; set; }
public decimal SizeLeft { get; set; }
public TimeSpan? TimeLeft { get; set; }
public DateTime? EstimatedCompletionTime { get; set; }
public DateTime? Added { get; set; }
public QueueStatus Status { get; set; }

View file

@ -67,8 +67,8 @@ namespace NzbDrone.Core.Queue
Quality = trackedDownload.RemoteEpisode?.ParsedEpisodeInfo.Quality ?? new QualityModel(Quality.Unknown),
Title = Parser.Parser.RemoveFileExtension(trackedDownload.DownloadItem.Title),
Size = trackedDownload.DownloadItem.TotalSize,
Sizeleft = trackedDownload.DownloadItem.RemainingSize,
Timeleft = trackedDownload.DownloadItem.RemainingTime,
SizeLeft = trackedDownload.DownloadItem.RemainingSize,
TimeLeft = trackedDownload.DownloadItem.RemainingTime,
Status = Enum.TryParse(trackedDownload.DownloadItem.Status.ToString(), out QueueStatus outValue) ? outValue : QueueStatus.Unknown,
TrackedDownloadStatus = trackedDownload.Status,
TrackedDownloadState = trackedDownload.State,
@ -86,9 +86,9 @@ namespace NzbDrone.Core.Queue
queue.Id = HashConverter.GetHashInt31($"trackedDownload-{trackedDownload.DownloadClient}-{trackedDownload.DownloadItem.DownloadId}-ep{episode?.Id ?? 0}");
if (queue.Timeleft.HasValue)
if (queue.TimeLeft.HasValue)
{
queue.EstimatedCompletionTime = DateTime.UtcNow.Add(queue.Timeleft.Value);
queue.EstimatedCompletionTime = DateTime.UtcNow.Add(queue.TimeLeft.Value);
}
return queue;

View file

@ -219,8 +219,8 @@ namespace Sonarr.Api.V3.Queue
if (pagingSpec.SortKey == "timeleft")
{
ordered = ascending
? fullQueue.OrderBy(q => q.Timeleft, new TimeleftComparer())
: fullQueue.OrderByDescending(q => q.Timeleft, new TimeleftComparer());
? fullQueue.OrderBy(q => q.TimeLeft, new TimeleftComparer())
: fullQueue.OrderByDescending(q => q.TimeLeft, new TimeleftComparer());
}
else if (pagingSpec.SortKey == "estimatedCompletionTime")
{
@ -271,7 +271,7 @@ namespace Sonarr.Api.V3.Queue
ordered = ascending ? fullQueue.OrderBy(orderByFunc) : fullQueue.OrderByDescending(orderByFunc);
}
ordered = ordered.ThenByDescending(q => q.Size == 0 ? 0 : 100 - (q.Sizeleft / q.Size * 100));
ordered = ordered.ThenByDescending(q => q.Size == 0 ? 0 : 100 - (q.SizeLeft / q.Size * 100));
pagingSpec.Records = ordered.Skip((pagingSpec.Page - 1) * pagingSpec.PageSize).Take(pagingSpec.PageSize).ToList();
pagingSpec.TotalRecords = fullQueue.Count;
@ -312,9 +312,9 @@ namespace Sonarr.Api.V3.Queue
return q => q.Size;
case "progress":
// Avoid exploding if a download's size is 0
return q => 100 - (q.Sizeleft / Math.Max(q.Size * 100, 1));
return q => 100 - (q.SizeLeft / Math.Max(q.Size * 100, 1));
default:
return q => q.Timeleft;
return q => q.TimeLeft;
}
}

View file

@ -26,8 +26,8 @@ namespace Sonarr.Api.V3.Queue
public int CustomFormatScore { get; set; }
public decimal Size { get; set; }
public string Title { get; set; }
public decimal Sizeleft { get; set; }
public TimeSpan? Timeleft { get; set; }
public decimal SizeLeft { get; set; }
public TimeSpan? TimeLeft { get; set; }
public DateTime? EstimatedCompletionTime { get; set; }
public DateTime? Added { get; set; }
public QueueStatus Status { get; set; }
@ -42,6 +42,11 @@ namespace Sonarr.Api.V3.Queue
public string Indexer { get; set; }
public string OutputPath { get; set; }
public bool EpisodeHasFile { get; set; }
[Obsolete]
public decimal Sizeleft { get; set; }
[Obsolete]
public TimeSpan? Timeleft { get; set; }
}
public static class QueueResourceMapper
@ -70,8 +75,8 @@ namespace Sonarr.Api.V3.Queue
CustomFormatScore = customFormatScore,
Size = model.Size,
Title = model.Title,
Sizeleft = model.Sizeleft,
Timeleft = model.Timeleft,
SizeLeft = model.SizeLeft,
TimeLeft = model.TimeLeft,
EstimatedCompletionTime = model.EstimatedCompletionTime,
Added = model.Added,
Status = model.Status,
@ -85,7 +90,12 @@ namespace Sonarr.Api.V3.Queue
DownloadClientHasPostImportCategory = model.DownloadClientHasPostImportCategory,
Indexer = model.Indexer,
OutputPath = model.OutputPath,
EpisodeHasFile = model.Episode?.HasFile ?? false
EpisodeHasFile = model.Episode?.HasFile ?? false,
#pragma warning disable CS0612
Sizeleft = model.SizeLeft,
Timeleft = model.TimeLeft,
#pragma warning restore CS0612
};
}