1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

episode detail is working but its a bit slow.

This commit is contained in:
kay.one 2013-03-03 15:18:43 -08:00
parent 4a4e440ec0
commit 9a738e3a65
16 changed files with 72 additions and 64 deletions

View File

@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using Nancy;
@ -17,12 +15,15 @@ public EpisodeModule(EpisodeService episodeService)
: base("/episodes")
{
_episodeService = episodeService;
Get["/{seriesId}"] = x => GetEpisodesForSeries(x.SeriesId);
Get["/"] = x => GetEpisodesForSeries();
}
private Response GetEpisodesForSeries(int seriesId)
private Response GetEpisodesForSeries()
{
var episodes = _episodeService.GetEpisodeBySeries(seriesId);
var seriesId = (int)Request.Query.SeriesId;
var seasonNumber = (int)Request.Query.SeasonNumber;
var episodes = _episodeService.GetEpisodesBySeason(seriesId, seasonNumber);
return Mapper.Map<List<Episode>, List<EpisodeResource>>(episodes).AsResponse();
}
}

View File

@ -122,24 +122,24 @@
<Content Include="Routing.js" />
<Content Include="Series\Delete\DeleteSeriesTemplate.html" />
<Content Include="Series\Delete\DeleteSeriesView.js" />
<Content Include="Series\Details\EpisodeCollection.js" />
<Content Include="Series\Details\EpisodeItemTemplate.html" />
<Content Include="Series\Details\EpisodeItemView.js" />
<Content Include="Series\Details\EpisodeModel.js" />
<Content Include="Series\Details\SeasonCollection.js" />
<Content Include="Series\Details\SeasonCompositeTemplate.html" />
<Content Include="Series\Details\SeasonCompositeView.js" />
<Content Include="Series\Details\SeasonModel.js" />
<Content Include="Series\Details\SeriesDetailsTemplate.html" />
<Content Include="Series\Details\SeriesDetailsView.js" />
<Content Include="Series\Edit\EditSeriesTemplate.html" />
<Content Include="Series\Edit\EditSeriesView.js" />
<Content Include="Series\EmptySeriesCollectionTemplate.html" />
<Content Include="Series\EpisodeCollection.js" />
<Content Include="Series\EpisodeModel.js" />
<Content Include="Series\Index\EmptySeriesIndexTemplate.html" />
<Content Include="Series\Index\SeriesIndexCollectionView.js" />
<Content Include="Series\Index\SeriesIndexTemplate.html" />
<Content Include="Series\Index\SeriesItemTemplate.html" />
<Content Include="Series\Index\SeriesItemView.js" />
<Content Include="Series\SeasonCollection.js" />
<Content Include="Series\SeasonModel.js" />
<Content Include="Series\SeriesCollection.js" />
<Content Include="Series\SeriesCollectionTemplate.html" />
<Content Include="Series\SeriesIndexCollectionView.js" />
<Content Include="Series\SeriesItemTemplate.html" />
<Content Include="Series\SeriesItemView.js" />
<Content Include="Series\SeriesModel.js" />
<Content Include="Shared\AutoComplete.js" />
<Content Include="Shared\NotFoundTemplate.html" />

View File

@ -9,5 +9,7 @@
<th>Controls</th>
</tr>
</thead>
<tbody></tbody>
<tbody class="x-episodes">
</tbody>
</table>

View File

@ -6,7 +6,11 @@ define(['app', 'Series/Details/EpisodeItemView'], function () {
template: 'Series/Details/SeasonCompositeTemplate',
initialize: function() {
this.collection =new NzbDrone.Series.EpisodeCollection();
this.collection.fetch({data: {
seriesId: this.model.get('seriesId'),
seasonNumber:this.model.get('seasonNumber')
}});
}
});
});

View File

@ -1,6 +1,6 @@
define(['app', 'Series/EpisodeModel'], function () {
NzbDrone.Series.EpisodeCollection = Backbone.Collection.extend({
url: NzbDrone.Constants.ApiRoot + '/episode',
url: NzbDrone.Constants.ApiRoot + '/episodes',
model: NzbDrone.Series.EpisodeModel
});
});

View File

@ -64,7 +64,7 @@ public void individual_missing_episode()
var episodes = Builder<Episode>.CreateListOfSize(1)
.All()
.With(e => e.Series = series)
.Build();
.Build().ToList();
WithEnableBacklogSearching();
@ -96,7 +96,7 @@ public void individual_missing_episodes_only()
var episodes = Builder<Episode>.CreateListOfSize(5)
.All()
.With(e => e.Series = series)
.Build();
.Build().ToList();
WithEnableBacklogSearching();
@ -126,7 +126,7 @@ public void series_season_missing_episodes_only_mismatch_count()
.All()
.With(e => e.Series = series)
.With(e => e.SeasonNumber = 1)
.Build();
.Build().ToList();
WithEnableBacklogSearching();
@ -160,7 +160,7 @@ public void series_season_missing_episodes_only()
.With(e => e.Series = series)
.With(e => e.SeriesId = series.Id)
.With(e => e.SeasonNumber = 1)
.Build();
.Build().ToList();
WithEnableBacklogSearching();
@ -202,7 +202,7 @@ public void multiple_missing_episodes()
.With(e => e.SeasonNumber = 1)
.TheNext(5)
.With(e => e.Series = series2)
.Build();
.Build().ToList();
WithEnableBacklogSearching();
@ -243,7 +243,7 @@ public void GetMissingForEnabledSeries_should_only_return_episodes_for_monitored
.With(e => e.SeasonNumber = 1)
.TheLast(6)
.With(e => e.Series = series[1])
.Build();
.Build().ToList();
WithEnableBacklogSearching();
@ -282,7 +282,7 @@ public void GetMissingForEnabledSeries_should_only_return_explicity_enabled_seri
.With(e => e.Series = series[1])
.TheNext(5)
.With(e => e.Series = series[2])
.Build();
.Build().ToList();
//WithEnableBacklogSearching();
@ -322,7 +322,7 @@ public void GetMissingForEnabledSeries_should_return_explicity_enabled_and_inher
.With(e => e.Series = series[1])
.TheNext(5)
.With(e => e.Series = series[2])
.Build();
.Build().ToList();
WithEnableBacklogSearching();

View File

@ -85,7 +85,7 @@ public void should_only_process_missing_episodes_from_the_last_30_days()
.With(e => e.AirDate = DateTime.Today.AddDays(-31)) //31 Days
.TheNext(5)
.With(e => e.AirDate = DateTime.Today.AddDays(-35))
.Build();
.Build().ToList();
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.EpisodesWithoutFiles(true)).Returns(episodes);
@ -119,7 +119,7 @@ public void GetMissingForEnabledSeries_should_only_return_episodes_for_monitored
.With(e => e.SeasonNumber = 1)
.TheLast(6)
.With(e => e.Series = series[1])
.Build();
.Build().ToList();
WithEnableBacklogSearching();
@ -158,7 +158,7 @@ public void GetMissingForEnabledSeries_should_only_return_explicity_enabled_seri
.With(e => e.Series = series[1])
.TheNext(5)
.With(e => e.Series = series[2])
.Build();
.Build().ToList();
//WithEnableBacklogSearching();
@ -198,7 +198,7 @@ public void GetMissingForEnabledSeries_should_return_explicity_enabled_and_inher
.With(e => e.Series = series[1])
.TheNext(5)
.With(e => e.Series = series[2])
.Build();
.Build().ToList();
WithEnableBacklogSearching();

View File

@ -22,7 +22,7 @@ namespace NzbDrone.Core.Test.JobTests
// ReSharper disable InconsistentNaming
public class SeasonSearchJobTest : CoreTest
{
private IList<Episode> _episodes;
private List<Episode> _episodes;
private ProgressNotification notification;
@ -37,7 +37,7 @@ public void Setup()
.With(e => e.SeasonNumber = 1)
.With(e => e.Ignored = false)
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
.Build();
.Build().ToList();
Mocker.GetMock<IEpisodeService>()
.Setup(c => c.GetEpisodesBySeason(1, 1)).Returns(_episodes);
@ -90,7 +90,7 @@ public void SeasonSearch_should_not_search_for_episodes_that_havent_aired_yet_or
.With(e => e.AirDate = DateTime.Today.AddDays(-1))
.TheLast(2)
.With(e => e.AirDate = DateTime.Today.AddDays(2))
.Build();
.Build().ToList();
Mocker.GetMock<IEpisodeService>()
.Setup(c => c.GetEpisodesBySeason(1, 1)).Returns(episodes);

View File

@ -90,7 +90,7 @@ public void should_move_file_if_a_conflict_is_found()
.All()
.With(e => e.SeriesId = seriesId)
.With(e => e.EpisodeFile = episodeFile)
.Build();
.Build().ToList();
Mocker.GetMock<IMediaFileService>().Setup(v => v.GetFileByPath(filename))
.Returns(() => null);

View File

@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
@ -250,7 +250,7 @@ public void import_new_multi_part_file_episode_has_equal_or_better_quality_than_
.With(e => e.EpisodeFile = Builder<EpisodeFile>.CreateNew()
.With(f => f.Quality = Quality.SDTV)
.Build())
.Build();
.Build().ToList();
With80MBFile();
@ -281,7 +281,7 @@ public void skip_import_new_multi_part_file_episode_existing_has_better_quality(
.With(e => e.EpisodeFile = Builder<EpisodeFile>.CreateNew()
.With(f => f.Quality = Quality.Bluray720p)
.Build())
.Build();
.Build().ToList();
//Mocks

View File

@ -39,7 +39,7 @@ public void should_not_move_file_if_source_and_destination_are_the_same_path()
.With(e => e.SeriesId = fakeSeries.Id)
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumber = 1)
.Build();
.Build().ToList();
const string filename = @"30 Rock - S01E01 - TBD";
var fi = new FileInfo(Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".avi"));
@ -85,7 +85,7 @@ public void should_use_EpisodeFiles_quality()
.With(e => e.SeriesId = fakeSeries.Id)
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumber = 1)
.Build();
.Build().ToList();
const string filename = @"30 Rock - S01E01 - TBD";
var fi = new FileInfo(Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".mkv"));
@ -137,7 +137,7 @@ public void should_log_error_and_return_null_when_source_file_does_not_exists()
.With(e => e.SeriesId = fakeSeries.Id)
.With(e => e.SeasonNumber = 1)
.With(e => e.EpisodeNumber = 1)
.Build();
.Build().ToList();
const string filename = @"30 Rock - S01E01 - TBD";
var fi = new FileInfo(Path.Combine(@"C:\Test\TV\30 Rock\Season 01\", filename + ".mkv"));

View File

@ -1,5 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using FizzWare.NBuilder;
using FluentAssertions;
using Moq;
@ -32,7 +32,7 @@ public void no_misnamed_files()
.TheNext(1)
.With(f => f.Id = 2)
.With(f => f.Path = @"C:\Test\Title2.avi")
.Build();
.Build().ToList();
var episodes = Builder<Episode>.CreateListOfSize(2)
.All()
@ -41,7 +41,7 @@ public void no_misnamed_files()
.With(e => e.EpisodeFile = episodeFiles[0])
.TheNext(1)
.With(e => e.EpisodeFile = episodeFiles[1])
.Build();
.Build().ToList();
WithStrictMocker();
@ -88,7 +88,7 @@ public void all_misnamed_files()
.With(e => e.EpisodeFile = episodeFiles[0])
.TheNext(1)
.With(e => e.EpisodeFile = episodeFiles[1])
.Build();
.Build().ToList();
WithStrictMocker();
@ -135,7 +135,7 @@ public void one_misnamed_file()
.With(e => e.EpisodeFile = episodeFiles[0])
.TheNext(1)
.With(e => e.EpisodeFile = episodeFiles[1])
.Build();
.Build().ToList();
WithStrictMocker();
@ -175,7 +175,7 @@ public void misnamed_multi_episode_file()
.TheNext(1)
.With(f => f.Id = 2)
.With(f => f.Path = @"C:\Test\Title2.avi")
.Build();
.Build().ToList();
var episodes = Builder<Episode>.CreateListOfSize(3)
.All()
@ -184,7 +184,7 @@ public void misnamed_multi_episode_file()
.With(e => e.EpisodeFile = episodeFiles[0])
.TheNext(1)
.With(e => e.EpisodeFile = episodeFiles[1])
.Build();
.Build().ToList();
WithStrictMocker();
@ -224,7 +224,7 @@ public void no_misnamed_multi_episode_file()
.TheNext(1)
.With(f => f.Id = 2)
.With(f => f.Path = @"C:\Test\Title2.avi")
.Build();
.Build().ToList();
var episodes = Builder<Episode>.CreateListOfSize(3)
.All()
@ -233,7 +233,7 @@ public void no_misnamed_multi_episode_file()
.With(e => e.EpisodeFile = episodeFiles[0])
.TheNext(1)
.With(e => e.EpisodeFile = episodeFiles[1])
.Build();
.Build().ToList();
WithStrictMocker();

View File

@ -30,7 +30,7 @@ public class ProcessResultsFixture : TestBase
private SearchHistory _searchHistory;
private ProgressNotification _notification;
private IList<Episode> _episodes;
private List<Episode> _episodes;
[SetUp]
public void Setup()
@ -50,7 +50,7 @@ public void Setup()
_episodes = Builder<Episode>
.CreateListOfSize(1)
.Build();
.Build().ToList();
Mocker.GetMock<IEpisodeService>()
.Setup(s => s.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>()))

View File

@ -18,14 +18,14 @@ public interface IEpisodeService
Episode GetEpisode(int seriesId, int seasonNumber, int episodeNumber);
Episode GetEpisode(int seriesId, DateTime date);
List<Episode> GetEpisodeBySeries(int seriesId);
IList<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber);
IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseResult);
IList<Episode> EpisodesWithoutFiles(bool includeSpecials);
IList<Episode> GetEpisodesByFileId(int episodeFileId);
IList<Episode> EpisodesWithFiles();
List<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber);
List<Episode> GetEpisodesByParseResult(EpisodeParseResult parseResult);
List<Episode> EpisodesWithoutFiles(bool includeSpecials);
List<Episode> GetEpisodesByFileId(int episodeFileId);
List<Episode> EpisodesWithFiles();
void RefreshEpisodeInfo(Series series);
void UpdateEpisode(Episode episode);
IList<int> GetEpisodeNumbersBySeason(int seriesId, int seasonNumber);
List<int> GetEpisodeNumbersBySeason(int seriesId, int seasonNumber);
void SetEpisodeIgnore(int episodeId, bool isIgnored);
bool IsFirstOrLastEpisodeOfSeason(int seriesId, int seasonNumber, int episodeNumber);
void SetPostDownloadStatus(List<int> episodeIds, PostDownloadStatusType postDownloadStatus);
@ -78,12 +78,12 @@ public List<Episode> GetEpisodeBySeries(int seriesId)
return _episodeRepository.GetEpisodes(seriesId).ToList();
}
public IList<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber)
public List<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber)
{
return _episodeRepository.GetEpisodes(seriesId, seasonNumber);
}
public IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseResult)
public List<Episode> GetEpisodesByParseResult(EpisodeParseResult parseResult)
{
var result = new List<Episode>();
@ -161,17 +161,17 @@ public IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseResult)
return result;
}
public IList<Episode> EpisodesWithoutFiles(bool includeSpecials)
public List<Episode> EpisodesWithoutFiles(bool includeSpecials)
{
return _episodeRepository.EpisodesWithoutFiles(includeSpecials);
}
public IList<Episode> GetEpisodesByFileId(int episodeFileId)
public List<Episode> GetEpisodesByFileId(int episodeFileId)
{
return _episodeRepository.GetEpisodeByFileId(episodeFileId);
}
public IList<Episode> EpisodesWithFiles()
public List<Episode> EpisodesWithFiles()
{
return _episodeRepository.EpisodesWithFiles();
}
@ -289,7 +289,7 @@ public void UpdateEpisode(Episode episode)
_episodeRepository.Update(episode);
}
public IList<int> GetEpisodeNumbersBySeason(int seriesId, int seasonNumber)
public List<int> GetEpisodeNumbersBySeason(int seriesId, int seasonNumber)
{
return GetEpisodesBySeason(seriesId, seasonNumber).Select(c => c.Id).ToList();
}

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using FizzWare.NBuilder;
using Moq;
using NUnit.Framework;
@ -91,7 +92,7 @@ public void should_not_stop_nzbdrone_service_if_service_isnt_installed()
[Test]
public void should_kill_nzbdrone_process_if_running()
{
var proccesses = Builder<ProcessInfo>.CreateListOfSize(2).Build();
var proccesses = Builder<ProcessInfo>.CreateListOfSize(2).Build().ToList();
Mocker.GetMock<ProcessProvider>()
.Setup(c => c.GetProcessByName(ProcessProvider.NzbDroneProccessName))