Calculate double episode start time on episode info refresh

pull/3113/head
markus101 12 years ago
parent 09deaf9ad1
commit fa2b2df7d5

@ -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<Episode>, List<CalendarResource>>(episodes).AsResponse();
}
}

@ -190,6 +190,22 @@ namespace NzbDrone.Core.Tv
}
}
var allEpisodes = new List<Episode>();
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<Episode> 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<int> 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<Episode> 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);
}
}
}

@ -7,6 +7,6 @@ define([
], function () {
NzbDrone.Calendar.CalendarItemView = Backbone.Marionette.ItemView.extend({
template : 'Calendar/CalendarItemTemplate',
tagName : 'div',
tagName : 'div'
});
});

@ -1,6 +0,0 @@
define(['app', 'Upcoming/UpcomingModel'], function () {
NzbDrone.Upcoming.UpcomingCollection = Backbone.Collection.extend({
url : NzbDrone.Constants.ApiRoot + '/upcoming',
model: NzbDrone.Upcoming.UpcomingModel
});
});

@ -1,65 +0,0 @@
<table class="table table-striped">
<thead>
<tr>
<th>Series Title</th>
<th>Episode</th>
<th>Episode Title</th>
<th>Air Time</th>
<th>Status</th>
</tr>
</thead>
<tbody id="yesterday">
<tr>
<td colspan="5">Yesterday</td>
</tr>
</tbody>
<tbody id="today">
<tr>
<td colspan="5">Today</td>
</tr>
</tbody>
<tbody id="tomorrow">
<tr>
<td colspan="5">Tomorrow</td>
</tr>
</tbody>
<tbody id="two_days">
<tr>
<td colspan="5">{{two_days}}</td>
</tr>
</tbody>
<tbody id="three_days">
<tr>
<td colspan="5">{{three_days}}</td>
</tr>
</tbody>
<tbody id="four_days">
<tr>
<td colspan="5">{{four_days}}</td>
</tr>
</tbody>
<tbody id="five_days">
<tr>
<td colspan="5">{{five_days}}</td>
</tr>
</tbody>
<tbody id="six_days">
<tr>
<td colspan="5">{{six_days}}</td>
</tr>
</tbody>
<tbody id="later">
<tr>
<td colspan="5">Later</td>
</tr>
</tbody>
</table>

@ -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
}
});
});

@ -1,5 +0,0 @@
<td>{{seriesTitle}}</td>
<td>{{seasonNumber}}x{{episodeNumber}}</td>
<td>{{episodeTitle}}</td>
<td>{{airTime}}</td>
<td>{{status}}</td>

@ -1,12 +0,0 @@
'use strict';
define([
'app',
'Upcoming/UpcomingCollection'
], function () {
NzbDrone.Upcoming.UpcomingItemView = Backbone.Marionette.ItemView.extend({
template: 'Upcoming/UpcomingItemTemplate',
tagName : 'tr',
});
});

@ -1,10 +0,0 @@
define(['app'], function (app) {
NzbDrone.Upcoming.UpcomingModel = Backbone.Model.extend({
mutators: {
},
defaults: {
status: 0
}
});
});
Loading…
Cancel
Save