1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-26 01:37:07 +00:00

Next airing will not show ignored episodes.

This commit is contained in:
Mark McDowall 2011-10-03 16:38:22 -07:00
parent ec6a0e6b7f
commit 7db08a10ec
2 changed files with 38 additions and 1 deletions

View file

@ -488,6 +488,7 @@ namespace NzbDrone.Core.Test
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.WhereAll()
.Have(e => e.SeriesId = fakeSeries.SeriesId)
.Have(e => e.Ignored = false)
.WhereTheFirst(1)
.Have(e => e.AirDate = DateTime.Today)
.AndTheRemaining()
@ -519,6 +520,7 @@ namespace NzbDrone.Core.Test
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.WhereAll()
.Have(e => e.SeriesId = fakeSeries.SeriesId)
.Have(e => e.Ignored = false)
.WhereTheFirst(1)
.Have(e => e.AirDate = DateTime.Today.AddDays(-1))
.AndTheRemaining()
@ -551,6 +553,7 @@ namespace NzbDrone.Core.Test
.WhereAll()
.Have(e => e.SeriesId = fakeSeries.SeriesId)
.Have(e => e.AirDate = null)
.Have(e => e.Ignored = false)
.Build();
db.Insert(fakeSeries);
@ -578,6 +581,7 @@ namespace NzbDrone.Core.Test
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.WhereAll()
.Have(e => e.SeriesId = fakeSeries.SeriesId)
.Have(e => e.Ignored = false)
.WhereTheFirst(1)
.Have(e => e.AirDate = DateTime.Today.AddDays(-1))
.AndTheRemaining()
@ -596,5 +600,38 @@ namespace NzbDrone.Core.Test
series.Should().HaveCount(1);
series[0].NextAiring.Should().Be(DateTime.Today.AddMonths(1));
}
[Test]
public void Get_Series_NextAiring_skip_ignored()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeSeries = Builder<Series>.CreateNew().With(e => e.QualityProfileId = fakeQuality.QualityProfileId).Build();
var fakeEpisodes = Builder<Episode>.CreateListOfSize(2)
.WhereAll()
.Have(e => e.SeriesId = fakeSeries.SeriesId)
.WhereTheFirst(1)
.Have(e => e.AirDate = DateTime.Today.AddDays(1))
.Have(e => e.Ignored = true)
.AndTheRemaining()
.Have(e => e.AirDate = DateTime.Today.AddMonths(1))
.Have(e => e.Ignored = false)
.Build();
db.Insert(fakeSeries);
db.Insert(fakeQuality);
db.InsertMany(fakeEpisodes);
//Act
mocker.Resolve<QualityProvider>();
var series = mocker.Resolve<SeriesProvider>().GetAllSeriesWithEpisodeCount();
//Assert
series.Should().HaveCount(1);
series[0].NextAiring.Should().Be(DateTime.Today.AddMonths(1));
}
}
}

View file

@ -49,7 +49,7 @@ namespace NzbDrone.Core.Providers
Series.Language, Series.Path, Series.Monitored, Series.QualityProfileId, Series.SeasonFolder,
SUM(CASE WHEN Ignored = 0 AND Airdate <= @0 THEN 1 ELSE 0 END) AS EpisodeCount,
SUM(CASE WHEN Episodes.Ignored = 0 AND Episodes.EpisodeFileId > 0 AND Episodes.AirDate <= @0 THEN 1 ELSE 0 END) as EpisodeFileCount,
MAX(Episodes.SeasonNumber) as SeasonCount, MIN(CASE WHEN AirDate < @0 THEN NULL ELSE AirDate END) as NextAiring,
MAX(Episodes.SeasonNumber) as SeasonCount, MIN(CASE WHEN AirDate < @0 OR Ignored = 1 THEN NULL ELSE AirDate END) as NextAiring,
QualityProfiles.QualityProfileId, QualityProfiles.Name, QualityProfiles.Cutoff, QualityProfiles.SonicAllowed
FROM Series
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId