From a184bb0784d8100691c8e5f2d8237efaccf3f0e7 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 9 Apr 2023 20:34:08 +0300 Subject: [PATCH] Fixed: (Core) Use MinBy and MaxBy --- src/NzbDrone.Common/Disk/DiskProviderBase.cs | 3 +-- src/NzbDrone.Core/History/HistoryRepository.cs | 8 ++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/NzbDrone.Common/Disk/DiskProviderBase.cs b/src/NzbDrone.Common/Disk/DiskProviderBase.cs index 9aa5ebdec..169f1a67d 100644 --- a/src/NzbDrone.Common/Disk/DiskProviderBase.cs +++ b/src/NzbDrone.Common/Disk/DiskProviderBase.cs @@ -478,8 +478,7 @@ 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) { diff --git a/src/NzbDrone.Core/History/HistoryRepository.cs b/src/NzbDrone.Core/History/HistoryRepository.cs index b1435c190..c19a6870f 100644 --- a/src/NzbDrone.Core/History/HistoryRepository.cs +++ b/src/NzbDrone.Core/History/HistoryRepository.cs @@ -31,9 +31,7 @@ public HistoryRepository(IMainDatabase database, IEventAggregator eventAggregato public History MostRecentForDownloadId(string downloadId) { - return FindByDownloadId(downloadId) - .OrderByDescending(h => h.Date) - .FirstOrDefault(); + return FindByDownloadId(downloadId).MaxBy(h => h.Date); } public List FindByDownloadId(string downloadId) @@ -75,9 +73,7 @@ public void Cleanup(int days) public History MostRecentForIndexer(int indexerId) { - return Query(x => x.IndexerId == indexerId) - .OrderByDescending(h => h.Date) - .FirstOrDefault(); + return Query(x => x.IndexerId == indexerId).MaxBy(h => h.Date); } public List Between(DateTime start, DateTime end)