From 9ffc0ec52155f149ff618404e65c39597208f367 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 6 Mar 2016 00:41:26 +0100 Subject: [PATCH] Fixed: Sort episodes on the api by episode number when they air at the same time. --- src/NzbDrone.Api/Calendar/CalendarFeedModule.cs | 2 +- src/NzbDrone.Api/Calendar/CalendarModule.cs | 2 +- src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs b/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs index 27301780f..d3ff5eac8 100644 --- a/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs +++ b/src/NzbDrone.Api/Calendar/CalendarFeedModule.cs @@ -51,7 +51,7 @@ private Response GetCalendarFeed() var episodes = _episodeService.EpisodesBetweenDates(start, end, false); var icalCalendar = new iCalendar(); - foreach (var episode in episodes.OrderBy(v => v.AirDateUtc.Value)) + foreach (var episode in episodes) { var occurrence = icalCalendar.Create(); occurrence.UID = "NzbDrone_episode_" + episode.Id.ToString(); diff --git a/src/NzbDrone.Api/Calendar/CalendarModule.cs b/src/NzbDrone.Api/Calendar/CalendarModule.cs index c89d5f52d..72960c143 100644 --- a/src/NzbDrone.Api/Calendar/CalendarModule.cs +++ b/src/NzbDrone.Api/Calendar/CalendarModule.cs @@ -35,7 +35,7 @@ private List GetCalendar() var resources = ToListResource(() => _episodeService.EpisodesBetweenDates(start, end, includeUnmonitored)); - return resources.OrderBy(e => e.AirDateUtc).ToList(); + return resources; } } } diff --git a/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs b/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs index 1b18d44c8..8ffdfa405 100644 --- a/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs +++ b/src/NzbDrone.Api/Episodes/EpisodeModuleWithSignalR.cs @@ -79,8 +79,15 @@ protected override List ToListResource(IEnumerable e.AirDateUtc.HasValue) + .ThenBy(e => e.AirDateUtc.Value) + .ThenBy(e => e.SeriesTitle) + .ThenByDescending(e => e.SeasonNumber != 0) + .ThenBy(e => e.SeasonNumber) + .ThenBy(e => e.EpisodeNumber) + .ToList(); } public void Handle(EpisodeGrabbedEvent message)