mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-17 15:02:34 +02:00
Use MinBy and MaxBy instead of OrderBy + First
Co-Authored-By: Stepan Goremykin <25577658+goremykin@users.noreply.github.com>
This commit is contained in:
parent
e0ad573e7f
commit
cc285fab45
@ -483,12 +483,11 @@ public virtual IMount GetMount(string path)
|
||||
|
||||
return mounts.Where(drive => drive.RootDirectory.PathEquals(path) ||
|
||||
drive.RootDirectory.IsParentPath(path))
|
||||
.OrderByDescending(drive => drive.RootDirectory.Length)
|
||||
.FirstOrDefault();
|
||||
.MaxBy(drive => drive.RootDirectory.Length);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Debug(ex, string.Format("Failed to get mount for path {0}", path));
|
||||
Logger.Debug(ex, $"Failed to get mount for path {path}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -239,8 +239,7 @@ public RemoteMovie OldestPendingRelease(int movieId)
|
||||
var movieReleases = GetPendingReleases(movieId);
|
||||
|
||||
return movieReleases.Select(r => r.RemoteMovie)
|
||||
.OrderByDescending(p => p.Release.AgeHours)
|
||||
.FirstOrDefault();
|
||||
.MaxBy(p => p.Release.AgeHours);
|
||||
}
|
||||
|
||||
private List<PendingRelease> GetPendingReleases()
|
||||
|
@ -37,9 +37,7 @@ public List<QualityModel> GetBestQualityInHistory(int movieId)
|
||||
|
||||
public MovieHistory MostRecentForDownloadId(string downloadId)
|
||||
{
|
||||
return FindByDownloadId(downloadId)
|
||||
.OrderByDescending(h => h.Date)
|
||||
.FirstOrDefault();
|
||||
return FindByDownloadId(downloadId).MaxBy(h => h.Date);
|
||||
}
|
||||
|
||||
public List<MovieHistory> FindByDownloadId(string downloadId)
|
||||
@ -90,9 +88,7 @@ protected override IEnumerable<MovieHistory> PagedQuery(SqlBuilder sql) =>
|
||||
|
||||
public MovieHistory MostRecentForMovie(int movieId)
|
||||
{
|
||||
return Query(x => x.MovieId == movieId)
|
||||
.OrderByDescending(h => h.Date)
|
||||
.FirstOrDefault();
|
||||
return Query(x => x.MovieId == movieId).MaxBy(h => h.Date);
|
||||
}
|
||||
|
||||
public List<MovieHistory> Since(DateTime date, MovieHistoryEventType? eventType)
|
||||
|
@ -182,9 +182,7 @@ public RootFolder Get(int id, bool timeout)
|
||||
|
||||
public string GetBestRootFolderPath(string path)
|
||||
{
|
||||
var possibleRootFolder = All().Where(r => r.Path.IsParentPath(path))
|
||||
.OrderByDescending(r => r.Path.Length)
|
||||
.FirstOrDefault();
|
||||
var possibleRootFolder = All().Where(r => r.Path.IsParentPath(path)).MaxBy(r => r.Path.Length);
|
||||
|
||||
if (possibleRootFolder == null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user