1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-23 02:05:27 +02: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 @@ private Queue.Queue GetQueueItem(PendingRelease pendingRelease, Lazy<DateTime> n
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 @@ private Queue.Queue GetQueueItem(PendingRelease pendingRelease, Lazy<DateTime> n
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 @@ public class Queue : ModelBase
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 @@ private Queue MapQueueItem(TrackedDownload trackedDownload, Episode episode)
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 @@ private Queue MapQueueItem(TrackedDownload trackedDownload, Episode episode)
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 @@ public PagingResource<QueueResource> GetQueue([FromQuery] PagingRequestResource
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 @@ public PagingResource<QueueResource> GetQueue([FromQuery] PagingRequestResource
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 @@ public PagingResource<QueueResource> GetQueue([FromQuery] PagingRequestResource
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 @@ public class QueueResource : RestResource
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 @@ public class QueueResource : RestResource
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 @@ public static QueueResource ToResource(this NzbDrone.Core.Queue.Queue model, boo
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 @@ public static QueueResource ToResource(this NzbDrone.Core.Queue.Queue model, boo
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
};
}