mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-10 04:52:42 +01:00
Fixed issue with missing episodes incorrectly using include specials.
Added tests for missing episodes.
This commit is contained in:
parent
45b4bb4629
commit
4f68d07c9a
@ -1103,5 +1103,120 @@ public void IgnoreSeason_RemoveIgnore()
|
||||
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IgnoreSeason_Ignore_Half()
|
||||
{
|
||||
var db = MockLib.GetEmptyDatabase();
|
||||
var mocker = new AutoMoqer();
|
||||
mocker.SetConstant(db);
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.WhereAll()
|
||||
.Have(c => c.SeriesId = 10)
|
||||
.Have(c => c.SeasonNumber = 1)
|
||||
.WhereTheFirst(2)
|
||||
.Have(c => c.Ignored = false)
|
||||
.AndTheRemaining()
|
||||
.Have(c => c.Ignored = true)
|
||||
.Build().ToList();
|
||||
|
||||
episodes.ForEach(c => db.Insert(c));
|
||||
|
||||
//Act
|
||||
mocker.Resolve<EpisodeProvider>().SetSeasonIgnore(10, 1, true);
|
||||
|
||||
//Assert
|
||||
var episodesInDb = db.Fetch<Episode>(@"SELECT * FROM Episodes");
|
||||
|
||||
episodesInDb.Should().HaveCount(4);
|
||||
episodesInDb.Where(e => e.Ignored).Should().HaveCount(4);
|
||||
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EpisodesWithoutFiles_no_specials()
|
||||
{
|
||||
var db = MockLib.GetEmptyDatabase();
|
||||
var mocker = new AutoMoqer();
|
||||
mocker.SetConstant(db);
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesId = 10)
|
||||
.Build();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.WhereAll()
|
||||
.Have(c => c.SeriesId = 10)
|
||||
.Have(c => c.SeasonNumber = 1)
|
||||
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
|
||||
.WhereTheFirst(2)
|
||||
.Have(c => c.EpisodeFileId = 0)
|
||||
.Build().ToList();
|
||||
|
||||
var specials = Builder<Episode>.CreateListOfSize(2)
|
||||
.WhereAll()
|
||||
.Have(c => c.SeriesId = 10)
|
||||
.Have(c => c.SeasonNumber = 0)
|
||||
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
|
||||
.Have(c => c.EpisodeFileId = 0)
|
||||
.Build().ToList();
|
||||
|
||||
db.Insert(series);
|
||||
db.InsertMany(episodes);
|
||||
db.InsertMany(specials);
|
||||
|
||||
//Act
|
||||
var missingFiles= mocker.Resolve<EpisodeProvider>().EpisodesWithoutFiles(false);
|
||||
|
||||
//Assert
|
||||
missingFiles.Should().HaveCount(2);
|
||||
missingFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(2);
|
||||
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EpisodesWithoutFiles_with_specials()
|
||||
{
|
||||
var db = MockLib.GetEmptyDatabase();
|
||||
var mocker = new AutoMoqer();
|
||||
mocker.SetConstant(db);
|
||||
|
||||
var series = Builder<Series>.CreateNew()
|
||||
.With(s => s.SeriesId = 10)
|
||||
.Build();
|
||||
|
||||
var episodes = Builder<Episode>.CreateListOfSize(4)
|
||||
.WhereAll()
|
||||
.Have(c => c.SeriesId = 10)
|
||||
.Have(c => c.SeasonNumber = 1)
|
||||
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
|
||||
.WhereTheFirst(2)
|
||||
.Have(c => c.EpisodeFileId = 0)
|
||||
.Build().ToList();
|
||||
|
||||
var specials = Builder<Episode>.CreateListOfSize(2)
|
||||
.WhereAll()
|
||||
.Have(c => c.SeriesId = 10)
|
||||
.Have(c => c.SeasonNumber = 0)
|
||||
.Have(c => c.AirDate = DateTime.Today.AddDays(-4))
|
||||
.Have(c => c.EpisodeFileId = 0)
|
||||
.Build().ToList();
|
||||
|
||||
db.Insert(series);
|
||||
db.InsertMany(episodes);
|
||||
db.InsertMany(specials);
|
||||
|
||||
//Act
|
||||
var missingFiles = mocker.Resolve<EpisodeProvider>().EpisodesWithoutFiles(true);
|
||||
|
||||
//Assert
|
||||
missingFiles.Should().HaveCount(4);
|
||||
missingFiles.Where(e => e.EpisodeFileId == 0).Should().HaveCount(4);
|
||||
|
||||
mocker.VerifyAllMocks();
|
||||
}
|
||||
}
|
||||
}
|
@ -159,12 +159,15 @@ public virtual IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseR
|
||||
|
||||
public virtual IList<Episode> EpisodesWithoutFiles(bool includeSpecials)
|
||||
{
|
||||
var episodes = _database.Query<Episode>("WHERE (EpisodeFileId=0 OR EpisodeFileId=NULL) AND AirDate<=@0",
|
||||
var episodes = _database.Query<Episode, Series>(@"SELECT Episodes.*, Series.Title FROM Episodes
|
||||
INNER JOIN Series
|
||||
ON Episodes.SeriesId = Series.SeriesId
|
||||
WHERE (EpisodeFileId=0 OR EpisodeFileId=NULL) AND AirDate<=@0",
|
||||
DateTime.Now.Date);
|
||||
if (includeSpecials)
|
||||
if (!includeSpecials)
|
||||
return episodes.Where(e => e.SeasonNumber > 0).ToList();
|
||||
|
||||
return AttachSeries(episodes.ToList());
|
||||
return episodes.ToList();
|
||||
}
|
||||
|
||||
public virtual IList<Episode> GetEpisodesByFileId(int episodeFileId)
|
||||
@ -298,8 +301,8 @@ public virtual void SetSeasonIgnore(long seriesId, int seasonNumber, bool isIgno
|
||||
Logger.Info("Setting ignore flag on Series:{0} Season:{1} to {2}", seriesId, seasonNumber, isIgnored);
|
||||
|
||||
_database.Execute(@"UPDATE Episodes SET Ignored = @0
|
||||
WHERE SeriesId = @1 AND SeasonNumber = @2",
|
||||
isIgnored, seriesId, seasonNumber);
|
||||
WHERE SeriesId = @1 AND SeasonNumber = @2 AND Ignored = @3",
|
||||
isIgnored, seriesId, seasonNumber, !isIgnored);
|
||||
|
||||
Logger.Info("Ignore flag for Series:{0} Season:{1} successfully set to {2}", seriesId, seasonNumber, isIgnored);
|
||||
}
|
||||
|
@ -26,10 +26,9 @@ public ActionResult Index()
|
||||
[GridAction]
|
||||
public ActionResult _AjaxBinding()
|
||||
{
|
||||
//TODO: possible subsonic bug, IQuarible causes some issues so ToList() is called
|
||||
//https://github.com/subsonic/SubSonic-3.0/issues/263
|
||||
var missingEpisodes = _episodeProvider.EpisodesWithoutFiles(false);
|
||||
|
||||
var missing = _episodeProvider.EpisodesWithoutFiles(true).Select(e => new MissingEpisodeModel
|
||||
var missing = missingEpisodes.Select(e => new MissingEpisodeModel
|
||||
{
|
||||
EpisodeId = e.EpisodeId,
|
||||
SeasonNumber = e.SeasonNumber,
|
||||
|
Loading…
Reference in New Issue
Block a user