diff --git a/NzbDrone.Api/Calendar/CalendarModule.cs b/NzbDrone.Api/Calendar/CalendarModule.cs index 7a2d2a99f..799b98215 100644 --- a/NzbDrone.Api/Calendar/CalendarModule.cs +++ b/NzbDrone.Api/Calendar/CalendarModule.cs @@ -33,21 +33,6 @@ namespace NzbDrone.Api.Calendar if(queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value); var episodes = _episodeService.EpisodesBetweenDates(start, end); - - //Todo: This should be done on episode data refresh - because it can be used in multiple places - var groups = episodes.GroupBy(e => new { e.SeriesId, e.AirDate }).Where(g => g.Count() > 1).ToList(); - - foreach (var group in groups) - { - //Order by Episode Number - int episodeCount = 0; - foreach (var episode in group.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber)) - { - episode.AirDate = episode.AirDate.Value.AddMinutes(episode.Series.Runtime * episodeCount); - episodeCount++; - } - } - return Mapper.Map, List>(episodes).AsResponse(); } } diff --git a/NzbDrone.Core/Tv/EpisodeService.cs b/NzbDrone.Core/Tv/EpisodeService.cs index 68478a348..e7372de78 100644 --- a/NzbDrone.Core/Tv/EpisodeService.cs +++ b/NzbDrone.Core/Tv/EpisodeService.cs @@ -190,6 +190,22 @@ namespace NzbDrone.Core.Tv } } + var allEpisodes = new List(); + allEpisodes.AddRange(newList); + allEpisodes.AddRange(updateList); + + var groups = allEpisodes.GroupBy(e => new { e.SeriesId, e.AirDate }).Where(g => g.Count() > 1).ToList(); + + foreach (var group in groups) + { + int episodeCount = 0; + foreach (var episode in group.OrderBy(e => e.SeasonNumber).ThenBy(e => e.EpisodeNumber)) + { + episode.AirDate = episode.AirDate.Value.AddMinutes(episode.Series.Runtime * episodeCount); + episodeCount++; + } + } + _episodeRepository.InsertMany(newList); _episodeRepository.UpdateMany(updateList); @@ -248,19 +264,6 @@ namespace NzbDrone.Core.Tv return false; } - private void DeleteEpisodesNotInTvdb(Series series, IEnumerable tvdbEpisodes) - { - //Todo: This will not work as currently implemented - what are we trying to do here? - return; - logger.Trace("Starting deletion of episodes that no longer exist in TVDB: {0}", series.Title.WithDefault(series.Id)); - foreach (var episode in tvdbEpisodes) - { - _episodeRepository.Delete(episode.Id); - } - - logger.Trace("Deleted episodes that no longer exist in TVDB for {0}", series.Id); - } - public void SetPostDownloadStatus(List episodeIds, PostDownloadStatusType postDownloadStatus) { if (episodeIds.Count == 0) throw new ArgumentException("episodeIds should contain one or more episode ids."); @@ -338,5 +341,18 @@ namespace NzbDrone.Core.Tv _logger.Debug("Linking [{0}] > [{1}]", message.EpisodeFile.Path, episode); } } + + private void DeleteEpisodesNotInTvdb(Series series, IEnumerable tvdbEpisodes) + { + //Todo: This will not work as currently implemented - what are we trying to do here? + return; + logger.Trace("Starting deletion of episodes that no longer exist in TVDB: {0}", series.Title.WithDefault(series.Id)); + foreach (var episode in tvdbEpisodes) + { + _episodeRepository.Delete(episode.Id); + } + + logger.Trace("Deleted episodes that no longer exist in TVDB for {0}", series.Id); + } } } \ No newline at end of file diff --git a/UI/Calendar/CalendarItemView.js b/UI/Calendar/CalendarItemView.js index b0da60732..a831616e1 100644 --- a/UI/Calendar/CalendarItemView.js +++ b/UI/Calendar/CalendarItemView.js @@ -7,6 +7,6 @@ define([ ], function () { NzbDrone.Calendar.CalendarItemView = Backbone.Marionette.ItemView.extend({ template : 'Calendar/CalendarItemTemplate', - tagName : 'div', + tagName : 'div' }); }); \ No newline at end of file diff --git a/UI/Upcoming/UpcomingCollection.js b/UI/Upcoming/UpcomingCollection.js deleted file mode 100644 index ec50c674d..000000000 --- a/UI/Upcoming/UpcomingCollection.js +++ /dev/null @@ -1,6 +0,0 @@ -define(['app', 'Upcoming/UpcomingModel'], function () { - NzbDrone.Upcoming.UpcomingCollection = Backbone.Collection.extend({ - url : NzbDrone.Constants.ApiRoot + '/upcoming', - model: NzbDrone.Upcoming.UpcomingModel - }); -}); \ No newline at end of file diff --git a/UI/Upcoming/UpcomingCollectionTemplate.html b/UI/Upcoming/UpcomingCollectionTemplate.html deleted file mode 100644 index 20acff46f..000000000 --- a/UI/Upcoming/UpcomingCollectionTemplate.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Series TitleEpisodeEpisode TitleAir TimeStatus
Yesterday
Today
Tomorrow
{{two_days}}
{{three_days}}
{{four_days}}
{{five_days}}
{{six_days}}
Later
\ No newline at end of file diff --git a/UI/Upcoming/UpcomingCollectionView.js b/UI/Upcoming/UpcomingCollectionView.js deleted file mode 100644 index 7d986c458..000000000 --- a/UI/Upcoming/UpcomingCollectionView.js +++ /dev/null @@ -1,88 +0,0 @@ -'use strict'; - -define(['app', 'Upcoming/UpcomingItemView'], function (app) { - NzbDrone.Upcoming.UpcomingCollectionView = Backbone.Marionette.CompositeView.extend({ - itemView : NzbDrone.Upcoming.UpcomingItemView, - template : 'Upcoming/UpcomingCollectionTemplate', - itemViewContainer: 'table', - - ui: { - yesterday : 'tbody#yesterday', - today : 'tbody#today', - tomorrow : 'tbody#tomorrow', - two_days : 'tbody#two_days', - three_days: 'tbody#three_days', - four_days : 'tbody#four_days', - five_days : 'tbody#five_days', - six_days : 'tbody#six_days', - later : 'tbody#later' - }, - - initialize: function () { - this.collection = new NzbDrone.Upcoming.UpcomingCollection(); - this.collection.fetch(); - }, - - serializeData: function () { - var viewData = {}; - viewData.two_days = Date.create().addDays(2).format('{Weekday}'); - viewData.three_days = Date.create().addDays(3).format('{Weekday}'); - viewData.four_days = Date.create().addDays(4).format('{Weekday}'); - viewData.five_days = Date.create().addDays(5).format('{Weekday}'); - viewData.six_days = Date.create().addDays(6).format('{Weekday}'); - return viewData; - }, - - appendHtml: function (collectionView, itemView, index) { - var date = Date.create(itemView.model.get('airTime')); - - if (date.isYesterday()) { - collectionView.$(this.ui.yesterday).append(itemView.el); - return; - } - - if (date.isToday()) { - collectionView.$(this.ui.today).append(itemView.el); - return; - } - - if (date.isTomorrow()) { - collectionView.$(this.ui.tomorrow).append(itemView.el); - return; - } - - if (date.is(Date.create().addDays(2).short())) { - collectionView.$(this.ui.two_days).append(itemView.el); - return; - } - - if (date.is(Date.create().addDays(3).short())) { - collectionView.$(this.ui.three_days).append(itemView.el); - return; - } - - if (date.is(Date.create().addDays(4).short())) { - collectionView.$(this.ui.four_days).append(itemView.el); - return; - } - - if (date.is(Date.create().addDays(5).short())) { - collectionView.$(this.ui.five_days).append(itemView.el); - return; - } - - if (date.is(Date.create().addDays(6).short())) { - collectionView.$(this.ui.six_days).append(itemView.el); - return; - } - - collectionView.$(this.ui.later).append(itemView.el); - - //if (date.isBefore(Date.create().addDays(7))) return date.format('{Weekday}'); - }, - - onCompositeCollectionRendered: function () { - //Might not need this :D - } - }); -}); \ No newline at end of file diff --git a/UI/Upcoming/UpcomingItemTemplate.html b/UI/Upcoming/UpcomingItemTemplate.html deleted file mode 100644 index b53ef04e9..000000000 --- a/UI/Upcoming/UpcomingItemTemplate.html +++ /dev/null @@ -1,5 +0,0 @@ -{{seriesTitle}} -{{seasonNumber}}x{{episodeNumber}} -{{episodeTitle}} -{{airTime}} -{{status}} \ No newline at end of file diff --git a/UI/Upcoming/UpcomingItemView.js b/UI/Upcoming/UpcomingItemView.js deleted file mode 100644 index b8830fccb..000000000 --- a/UI/Upcoming/UpcomingItemView.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -define([ - 'app', - 'Upcoming/UpcomingCollection' - -], function () { - NzbDrone.Upcoming.UpcomingItemView = Backbone.Marionette.ItemView.extend({ - template: 'Upcoming/UpcomingItemTemplate', - tagName : 'tr', - }); -}); \ No newline at end of file diff --git a/UI/Upcoming/UpcomingModel.js b/UI/Upcoming/UpcomingModel.js deleted file mode 100644 index 4acf9434e..000000000 --- a/UI/Upcoming/UpcomingModel.js +++ /dev/null @@ -1,10 +0,0 @@ -define(['app'], function (app) { - NzbDrone.Upcoming.UpcomingModel = Backbone.Model.extend({ - mutators: { - - }, - defaults: { - status: 0 - } - }); -});