Fixed: Sort episodes on the api by episode number when they air at the same time.

This commit is contained in:
Taloth Saldono 2016-03-06 00:41:26 +01:00
parent b598add64e
commit 9ffc0ec521
3 changed files with 10 additions and 3 deletions

View File

@ -51,7 +51,7 @@ namespace NzbDrone.Api.Calendar
var episodes = _episodeService.EpisodesBetweenDates(start, end, false); var episodes = _episodeService.EpisodesBetweenDates(start, end, false);
var icalCalendar = new iCalendar(); var icalCalendar = new iCalendar();
foreach (var episode in episodes.OrderBy(v => v.AirDateUtc.Value)) foreach (var episode in episodes)
{ {
var occurrence = icalCalendar.Create<Event>(); var occurrence = icalCalendar.Create<Event>();
occurrence.UID = "NzbDrone_episode_" + episode.Id.ToString(); occurrence.UID = "NzbDrone_episode_" + episode.Id.ToString();

View File

@ -35,7 +35,7 @@ namespace NzbDrone.Api.Calendar
var resources = ToListResource(() => _episodeService.EpisodesBetweenDates(start, end, includeUnmonitored)); var resources = ToListResource(() => _episodeService.EpisodesBetweenDates(start, end, includeUnmonitored));
return resources.OrderBy(e => e.AirDateUtc).ToList(); return resources;
} }
} }
} }

View File

@ -79,8 +79,15 @@ namespace NzbDrone.Api.Episodes
{ {
var resources = base.ToListResource(modelList); var resources = base.ToListResource(modelList);
return LoadSeries(resources); var withSeries = LoadSeries(resources);
return withSeries.OrderByDescending(e => 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) public void Handle(EpisodeGrabbedEvent message)