From 9a738e3a6593369bdf70846a4a7ce72f9b002766 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 3 Mar 2013 15:18:43 -0800 Subject: [PATCH] episode detail is working but its a bit slow. --- NzbDrone.Api/Episodes/EpisodeModule.cs | 13 +++++----- NzbDrone.Backbone/NzbDrone.Backbone.csproj | 18 ++++++------- .../Details/SeasonCompositeTemplate.html | 4 ++- .../Series/Details/SeasonCompositeView.js | 6 ++++- NzbDrone.Backbone/Series/EpisodeCollection.js | 2 +- .../JobTests/BacklogSearchJobTest.cs | 16 ++++++------ .../JobTests/RecentBacklogSearchJobTest.cs | 8 +++--- .../JobTests/SeasonSearchJobTest.cs | 6 ++--- .../CleanUpDropFolderFixture.cs | 2 +- .../ImportFileFixture.cs | 6 ++--- .../MoveEpisodeFileFixture.cs | 6 ++--- .../ProviderTests/MisnamedProviderTest.cs | 18 ++++++------- .../SearchTests/ProcessResultsFixture.cs | 4 +-- NzbDrone.Core/Tv/EpisodeRepository.cs | Bin 7033 -> 7023 bytes NzbDrone.Core/Tv/EpisodeService.cs | 24 +++++++++--------- .../UpdateProviderStartFixture.cs | 3 ++- 16 files changed, 72 insertions(+), 64 deletions(-) diff --git a/NzbDrone.Api/Episodes/EpisodeModule.cs b/NzbDrone.Api/Episodes/EpisodeModule.cs index 290c7e07b..59db1477b 100644 --- a/NzbDrone.Api/Episodes/EpisodeModule.cs +++ b/NzbDrone.Api/Episodes/EpisodeModule.cs @@ -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>(episodes).AsResponse(); } } diff --git a/NzbDrone.Backbone/NzbDrone.Backbone.csproj b/NzbDrone.Backbone/NzbDrone.Backbone.csproj index ee28ad25d..10d427023 100644 --- a/NzbDrone.Backbone/NzbDrone.Backbone.csproj +++ b/NzbDrone.Backbone/NzbDrone.Backbone.csproj @@ -122,24 +122,24 @@ - - - - - + + + + + + + + + - - - - diff --git a/NzbDrone.Backbone/Series/Details/SeasonCompositeTemplate.html b/NzbDrone.Backbone/Series/Details/SeasonCompositeTemplate.html index a42dcd314..f71621a3b 100644 --- a/NzbDrone.Backbone/Series/Details/SeasonCompositeTemplate.html +++ b/NzbDrone.Backbone/Series/Details/SeasonCompositeTemplate.html @@ -9,5 +9,7 @@ Controls - + + + \ No newline at end of file diff --git a/NzbDrone.Backbone/Series/Details/SeasonCompositeView.js b/NzbDrone.Backbone/Series/Details/SeasonCompositeView.js index 074c26dba..ed59be591 100644 --- a/NzbDrone.Backbone/Series/Details/SeasonCompositeView.js +++ b/NzbDrone.Backbone/Series/Details/SeasonCompositeView.js @@ -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') + }}); } }); }); \ No newline at end of file diff --git a/NzbDrone.Backbone/Series/EpisodeCollection.js b/NzbDrone.Backbone/Series/EpisodeCollection.js index 8c5aaf731..3d22c47c1 100644 --- a/NzbDrone.Backbone/Series/EpisodeCollection.js +++ b/NzbDrone.Backbone/Series/EpisodeCollection.js @@ -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 }); }); \ No newline at end of file diff --git a/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs index 8d9a7fd6a..70f43af98 100644 --- a/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/BacklogSearchJobTest.cs @@ -64,7 +64,7 @@ public void individual_missing_episode() var episodes = Builder.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.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(); diff --git a/NzbDrone.Core.Test/JobTests/RecentBacklogSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/RecentBacklogSearchJobTest.cs index 08354e383..3c6bc7077 100644 --- a/NzbDrone.Core.Test/JobTests/RecentBacklogSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/RecentBacklogSearchJobTest.cs @@ -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() .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(); diff --git a/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs b/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs index 678e8b7de..5a02b1cda 100644 --- a/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/SeasonSearchJobTest.cs @@ -22,7 +22,7 @@ namespace NzbDrone.Core.Test.JobTests // ReSharper disable InconsistentNaming public class SeasonSearchJobTest : CoreTest { - private IList _episodes; + private List _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() .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() .Setup(c => c.GetEpisodesBySeason(1, 1)).Returns(episodes); diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpDropFolderFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpDropFolderFixture.cs index 0fd1df5b6..aea3f01be 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpDropFolderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/CleanUpDropFolderFixture.cs @@ -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().Setup(v => v.GetFileByPath(filename)) .Returns(() => null); diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs index eacec038f..d2a8617e4 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/ImportFileFixture.cs @@ -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.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.CreateNew() .With(f => f.Quality = Quality.Bluray720p) .Build()) - .Build(); + .Build().ToList(); //Mocks diff --git a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs index d7be6c148..98f7363ca 100644 --- a/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/DiskScanProviderTests/MoveEpisodeFileFixture.cs @@ -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")); diff --git a/NzbDrone.Core.Test/ProviderTests/MisnamedProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/MisnamedProviderTest.cs index 97d129e33..24debc39b 100644 --- a/NzbDrone.Core.Test/ProviderTests/MisnamedProviderTest.cs +++ b/NzbDrone.Core.Test/ProviderTests/MisnamedProviderTest.cs @@ -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.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.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.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(); diff --git a/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs b/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs index cc1f255fa..a03c204c6 100644 --- a/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/SearchTests/ProcessResultsFixture.cs @@ -30,7 +30,7 @@ public class ProcessResultsFixture : TestBase private SearchHistory _searchHistory; private ProgressNotification _notification; - private IList _episodes; + private List _episodes; [SetUp] public void Setup() @@ -50,7 +50,7 @@ public void Setup() _episodes = Builder .CreateListOfSize(1) - .Build(); + .Build().ToList(); Mocker.GetMock() .Setup(s => s.GetEpisodesByParseResult(It.IsAny())) diff --git a/NzbDrone.Core/Tv/EpisodeRepository.cs b/NzbDrone.Core/Tv/EpisodeRepository.cs index 40a5c260ce828e51d48cb4a87fa1d4ddbaa9cdaf..9626c35bed92d61369ee6c5b6cc9cd382c02c530 100644 GIT binary patch delta 104 zcmexq_TFqmAmb!9^~sft+>_YUCa-3co5UtDxrJS1@^L1`$qpP!ldYJtCtqR`1F~5* xA7HX)p2RjAqEdMBbxy6x|JiaNI+jjW<`&!Rz~RRPVt|xSKETAjc>~u;0RR)iA;SOw delta 106 zcmaEF_S0-bAS0va;&BALNb k>XQ}OO5j>n!j+3mp1?j4s8Eq3g$XFQkV$d#GOm*X0I GetEpisodeBySeries(int seriesId); - IList GetEpisodesBySeason(int seriesId, int seasonNumber); - IList GetEpisodesByParseResult(EpisodeParseResult parseResult); - IList EpisodesWithoutFiles(bool includeSpecials); - IList GetEpisodesByFileId(int episodeFileId); - IList EpisodesWithFiles(); + List GetEpisodesBySeason(int seriesId, int seasonNumber); + List GetEpisodesByParseResult(EpisodeParseResult parseResult); + List EpisodesWithoutFiles(bool includeSpecials); + List GetEpisodesByFileId(int episodeFileId); + List EpisodesWithFiles(); void RefreshEpisodeInfo(Series series); void UpdateEpisode(Episode episode); - IList GetEpisodeNumbersBySeason(int seriesId, int seasonNumber); + List GetEpisodeNumbersBySeason(int seriesId, int seasonNumber); void SetEpisodeIgnore(int episodeId, bool isIgnored); bool IsFirstOrLastEpisodeOfSeason(int seriesId, int seasonNumber, int episodeNumber); void SetPostDownloadStatus(List episodeIds, PostDownloadStatusType postDownloadStatus); @@ -78,12 +78,12 @@ public List GetEpisodeBySeries(int seriesId) return _episodeRepository.GetEpisodes(seriesId).ToList(); } - public IList GetEpisodesBySeason(int seriesId, int seasonNumber) + public List GetEpisodesBySeason(int seriesId, int seasonNumber) { return _episodeRepository.GetEpisodes(seriesId, seasonNumber); } - public IList GetEpisodesByParseResult(EpisodeParseResult parseResult) + public List GetEpisodesByParseResult(EpisodeParseResult parseResult) { var result = new List(); @@ -161,17 +161,17 @@ public IList GetEpisodesByParseResult(EpisodeParseResult parseResult) return result; } - public IList EpisodesWithoutFiles(bool includeSpecials) + public List EpisodesWithoutFiles(bool includeSpecials) { return _episodeRepository.EpisodesWithoutFiles(includeSpecials); } - public IList GetEpisodesByFileId(int episodeFileId) + public List GetEpisodesByFileId(int episodeFileId) { return _episodeRepository.GetEpisodeByFileId(episodeFileId); } - public IList EpisodesWithFiles() + public List EpisodesWithFiles() { return _episodeRepository.EpisodesWithFiles(); } @@ -289,7 +289,7 @@ public void UpdateEpisode(Episode episode) _episodeRepository.Update(episode); } - public IList GetEpisodeNumbersBySeason(int seriesId, int seasonNumber) + public List GetEpisodeNumbersBySeason(int seriesId, int seasonNumber) { return GetEpisodesBySeason(seriesId, seasonNumber).Select(c => c.Id).ToList(); } diff --git a/NzbDrone.Update.Test/UpdateProviderStartFixture.cs b/NzbDrone.Update.Test/UpdateProviderStartFixture.cs index 4ed2fe116..fd5ff433a 100644 --- a/NzbDrone.Update.Test/UpdateProviderStartFixture.cs +++ b/NzbDrone.Update.Test/UpdateProviderStartFixture.cs @@ -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.CreateListOfSize(2).Build(); + var proccesses = Builder.CreateListOfSize(2).Build().ToList(); Mocker.GetMock() .Setup(c => c.GetProcessByName(ProcessProvider.NzbDroneProccessName))