diff --git a/NzbDrone.Api/AutomapperBootstraper.cs b/NzbDrone.Api/AutomapperBootstraper.cs index 8d30bba7d..336ade642 100644 --- a/NzbDrone.Api/AutomapperBootstraper.cs +++ b/NzbDrone.Api/AutomapperBootstraper.cs @@ -5,8 +5,6 @@ using NzbDrone.Api.QualityType; using NzbDrone.Api.Resolvers; using NzbDrone.Api.Series; -using NzbDrone.Api.Upcoming; -using NzbDrone.Core.Datastore; using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; @@ -43,11 +41,6 @@ public static void InitializeAutomapper() .ForMember(dest => dest.BacklogSetting, opt => opt.MapFrom(src => (Int32)src.BacklogSetting)) .ForMember(dest => dest.NextAiring, opt => opt.ResolveUsing()); - //Upcoming - Mapper.CreateMap() - .ForMember(dest => dest.SeriesTitle, opt => opt.MapFrom(src => src.Series.Title)) - .ForMember(dest => dest.EpisodeTitle, opt => opt.MapFrom(src => src.Title)); - //Calendar Mapper.CreateMap() .ForMember(dest => dest.SeriesTitle, opt => opt.MapFrom(src => src.Series.Title)) diff --git a/NzbDrone.Api/Calendar/CalendarModule.cs b/NzbDrone.Api/Calendar/CalendarModule.cs index 4c8141b54..6d14ab384 100644 --- a/NzbDrone.Api/Calendar/CalendarModule.cs +++ b/NzbDrone.Api/Calendar/CalendarModule.cs @@ -17,10 +17,10 @@ public CalendarModule(EpisodeService episodeService) : base("/calendar") { _episodeService = episodeService; - Get["/"] = x => Calendar(); + Get["/"] = x => GetEpisodesBetweenStartAndEndDate(); } - private Response Calendar() + private Response GetEpisodesBetweenStartAndEndDate() { var start = DateTime.Today; var end = DateTime.Today.AddDays(7); diff --git a/NzbDrone.Api/NzbDrone.Api.csproj b/NzbDrone.Api/NzbDrone.Api.csproj index 10a6bf43b..d6ce23cba 100644 --- a/NzbDrone.Api/NzbDrone.Api.csproj +++ b/NzbDrone.Api/NzbDrone.Api.csproj @@ -142,8 +142,6 @@ - - diff --git a/NzbDrone.Api/Upcoming/UpcomingModule.cs b/NzbDrone.Api/Upcoming/UpcomingModule.cs deleted file mode 100644 index 3ca1f0486..000000000 --- a/NzbDrone.Api/Upcoming/UpcomingModule.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using AutoMapper; -using FluentValidation; -using Nancy; -using NzbDrone.Api.Extensions; -using NzbDrone.Api.Series; -using NzbDrone.Common; -using NzbDrone.Core.Jobs; -using NzbDrone.Core.Model; -using NzbDrone.Core.Providers; -using NzbDrone.Core.Tv; - -namespace NzbDrone.Api.Upcoming -{ - public class UpcomingModule : NzbDroneApiModule - { - private readonly UpcomingEpisodesProvider _upcomingEpisodesProvider; - - public UpcomingModule(UpcomingEpisodesProvider upcomingEpisodesProvider) - : base("/Upcoming") - { - _upcomingEpisodesProvider = upcomingEpisodesProvider; - Get["/"] = x => Upcoming(); - } - - private Response Upcoming() - { - var upcoming = _upcomingEpisodesProvider.UpcomingEpisodes(); - return Mapper.Map, List>(upcoming).AsResponse(); - } - } -} \ No newline at end of file diff --git a/NzbDrone.Api/Upcoming/UpcomingResource.cs b/NzbDrone.Api/Upcoming/UpcomingResource.cs deleted file mode 100644 index fd6d5ed80..000000000 --- a/NzbDrone.Api/Upcoming/UpcomingResource.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NzbDrone.Api.QualityProfiles; -using NzbDrone.Core.Model; - -namespace NzbDrone.Api.Upcoming -{ - public class UpcomingResource - { - public Int32 SeriesId { get; set; } - public String SeriesTitle { get; set; } - - public Int32 EpisodeId { get; set; } - public String EpisodeTitle { get; set; } - public Int32 SeasonNumber { get; set; } - public Int32 EpisodeNumber { get; set; } - public DateTime? AirTime { get; set; } - public Int32 Status { get; set; } - public String Overview { get; set; } - } -} diff --git a/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs index 6d8f1f6b8..b761e61cf 100644 --- a/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs +++ b/NzbDrone.Core.Test/JobTests/DiskScanJobTest.cs @@ -29,10 +29,9 @@ public void series_specific_scan_should_scan_series() .With(s => s.Id = 12) .Build(); - Mocker.GetMock() - .Setup(p => p.Get(series.Id)); - + .Setup(p => p.Get(series.Id)) + .Returns(series); Mocker.GetMock() .Setup(p => p.Scan(series)) @@ -120,14 +119,10 @@ public void job_with_no_target_should_scan_series_with_episodes() .Setup(s => s.Scan(series[1])) .Returns(new List()); - Mocker.Resolve().Start(new ProgressNotification("Test"), null); - - Mocker.VerifyAllMocks(); Mocker.GetMock().Verify(s => s.Scan(It.IsAny()), Times.Exactly(2)); } } - } \ No newline at end of file diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index d61e5701a..c011c01dd 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -232,7 +232,6 @@ - diff --git a/NzbDrone.Core.Test/ProviderTests/UpcomingEpisodesProviderTest.cs b/NzbDrone.Core.Test/ProviderTests/UpcomingEpisodesProviderTest.cs deleted file mode 100644 index 864a40d4a..000000000 --- a/NzbDrone.Core.Test/ProviderTests/UpcomingEpisodesProviderTest.cs +++ /dev/null @@ -1,91 +0,0 @@ -// ReSharper disable InconsistentNaming -using System; -using System.Collections.Generic; -using System.Linq; -using FizzWare.NBuilder; -using FluentAssertions; -using NUnit.Framework; -using NzbDrone.Core.Tv; -using NzbDrone.Core.Providers; -using NzbDrone.Core.Repository; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.ProviderTests -{ - [TestFixture] - - public class UpcomingEpisodesProviderTest : SqlCeTest - { - private IList episodes; - private Series series; - - [SetUp] - public void Setup() - { - WithRealDb(); - - episodes = Builder.CreateListOfSize(6) - .All() - .With(e => e.SeriesId = 1) - .With(e => e.Ignored = false) - .TheFirst(1) - .With(e => e.AirDate = DateTime.Today.AddDays(-1)) - .TheNext(1) - .With(e => e.AirDate = DateTime.Today) - .TheNext(1) - .With(e => e.AirDate = DateTime.Today.AddDays(1)) - .TheNext(1) - .With(e => e.AirDate = DateTime.Today.AddDays(2)) - .TheNext(1) - .With(e => e.AirDate = DateTime.Today.AddDays(7)) - .TheNext(1) - .With(e => e.AirDate = DateTime.Today.AddDays(9)) - .Build(); - - series = Builder.CreateNew() - .With(s => s.Id = 1) - .And(c => c.Monitored = true) - .Build(); - - - Db.InsertMany(episodes); - Db.Insert(series); - } - - private void WithIgnoredEpisodes() - { - episodes.ToList().ForEach(c => c.Ignored = true); - Db.UpdateMany(episodes); - } - - private void WithIgnoredSeries() - { - series.Monitored = false; - Db.Update(series); - } - - [Test] - public void Get_UpcomingEpisodes() - { - var result = Mocker.Resolve().UpcomingEpisodes(); - - //Assert - result.Should().HaveCount(5); - result.Should().OnlyContain(c => c.Series != null && c.SeriesId == series.Id); - } - - [Test] - public void Get_UpcomingEpisodes_should_skip_ingored() - { - WithIgnoredEpisodes(); - Mocker.Resolve().UpcomingEpisodes().Should().BeEmpty(); - } - - [Test] - public void Get_UpcomingEpisodes_should_skip_unmonitored_series() - { - WithIgnoredSeries(); - Mocker.Resolve().UpcomingEpisodes().Should().BeEmpty(); - } - } -} diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 62c3e4f91..67df16954 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -561,9 +561,6 @@ Code - - Code - Code diff --git a/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs b/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs deleted file mode 100644 index 99fcfc801..000000000 --- a/NzbDrone.Core/Providers/UpcomingEpisodesProvider.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using NzbDrone.Core.Tv; -using PetaPoco; - -namespace NzbDrone.Core.Providers -{ - public class UpcomingEpisodesProvider - { - private readonly IDatabase _database; - - public UpcomingEpisodesProvider(IDatabase database) - { - _database = database; - } - - //Todo: Might be best if this is part of episode repo (when its there) - public virtual List UpcomingEpisodes() - { - return _database.Fetch(@"SELECT * FROM Episodes - INNER JOIN Series ON Episodes.SeriesId = Series.SeriesId - WHERE Series.Monitored = 1 AND Ignored = 0 AND AirDate BETWEEN @0 AND @1" - ,DateTime.Today.AddDays(-1).Date, DateTime.Today.AddDays(8).Date); - } - } -} \ No newline at end of file