mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-05 02:22:31 +01:00
Monitored instead of ignored for episodes and seasons
This commit is contained in:
parent
5b226a4a5e
commit
41baecc2ee
@ -16,7 +16,7 @@ public class EpisodeResource : RestResource
|
||||
public EpisodeFile EpisodeFile { get; set; }
|
||||
|
||||
public Boolean HasFile { get; set; }
|
||||
public Boolean Ignored { get; set; }
|
||||
public Boolean Monitored { get; set; }
|
||||
public Int32 SceneEpisodeNumber { get; set; }
|
||||
public Int32 SceneSeasonNumber { get; set; }
|
||||
public Int32 TvDbEpisodeId { get; set; }
|
||||
|
@ -30,8 +30,8 @@ public void Setup()
|
||||
.With(c => c.Monitored = true)
|
||||
.Build();
|
||||
|
||||
_firstEpisode = new Episode { Ignored = false };
|
||||
_secondEpisode = new Episode { Ignored = false };
|
||||
_firstEpisode = new Episode { Monitored = true };
|
||||
_secondEpisode = new Episode { Monitored = true };
|
||||
|
||||
|
||||
var singleEpisodeList = new List<Episode> { _firstEpisode };
|
||||
@ -48,20 +48,16 @@ public void Setup()
|
||||
Series = _fakeSeries,
|
||||
Episodes = singleEpisodeList
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void WithFirstEpisodeIgnored()
|
||||
private void WithFirstEpisodeUnmonitored()
|
||||
{
|
||||
_firstEpisode.Ignored = true;
|
||||
_firstEpisode.Monitored = false;
|
||||
}
|
||||
|
||||
private void WithSecondEpisodeIgnored()
|
||||
private void WithSecondEpisodeUnmonitored()
|
||||
{
|
||||
_secondEpisode.Ignored = true;
|
||||
_secondEpisode.Monitored = false;
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -81,34 +77,34 @@ public void not_monitored_series_should_be_skipped()
|
||||
|
||||
|
||||
[Test]
|
||||
public void only_episode_ignored_should_return_false()
|
||||
public void only_episode_not_monitored_should_return_false()
|
||||
{
|
||||
WithFirstEpisodeIgnored();
|
||||
WithFirstEpisodeUnmonitored();
|
||||
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultSingle).Should().BeFalse();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void both_episodes_ignored_should_return_false()
|
||||
public void both_episodes_not_monitored_should_return_false()
|
||||
{
|
||||
WithFirstEpisodeIgnored();
|
||||
WithSecondEpisodeIgnored();
|
||||
WithFirstEpisodeUnmonitored();
|
||||
WithSecondEpisodeUnmonitored();
|
||||
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeFalse();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void only_first_episode_ignored_should_return_monitored()
|
||||
public void only_first_episode_not_monitored_should_return_monitored()
|
||||
{
|
||||
WithFirstEpisodeIgnored();
|
||||
WithFirstEpisodeUnmonitored();
|
||||
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void only_second_episode_ignored_should_return_monitored()
|
||||
public void only_second_episode_not_monitored_should_return_monitored()
|
||||
{
|
||||
WithSecondEpisodeIgnored();
|
||||
WithSecondEpisodeUnmonitored();
|
||||
_monitoredEpisodeSpecification.IsSatisfiedBy(_parseResultMulti).Should().BeTrue();
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
/*
|
||||
//TODO: Alrighty then... We should delete this or uncomment some of these tests...
|
||||
|
||||
/*
|
||||
|
||||
|
||||
using System;
|
||||
|
@ -13,26 +13,25 @@ namespace NzbDrone.Core.Test.TvTests
|
||||
{
|
||||
public class SeasonProviderTest : DbTest<SeasonRepository, Season>
|
||||
{
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public void IsIgnored_should_return_ignored_status_of_season(bool ignoreFlag)
|
||||
public void Ismonitored_should_return_monitored_status_of_season(bool monitored)
|
||||
{
|
||||
var fakeSeason = Builder<Season>.CreateNew()
|
||||
.With(s => s.Ignored = ignoreFlag)
|
||||
.With(s => s.Monitored = monitored)
|
||||
.BuildNew<Season>();
|
||||
|
||||
Db.Insert(fakeSeason);
|
||||
|
||||
var result = Subject.IsIgnored(fakeSeason.SeriesId, fakeSeason.SeasonNumber);
|
||||
var result = Subject.IsMonitored(fakeSeason.SeriesId, fakeSeason.SeasonNumber);
|
||||
|
||||
result.Should().Be(ignoreFlag);
|
||||
result.Should().Be(monitored);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsIgnored_should_return_false_if_not_in_db()
|
||||
public void Monitored_should_return_true_if_not_in_db()
|
||||
{
|
||||
Subject.IsIgnored(10, 0).Should().BeFalse();
|
||||
Subject.IsMonitored(10, 0).Should().BeTrue();
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -142,10 +142,10 @@ public string UpdateUrl
|
||||
set { SetValue("UpdateUrl", value); }
|
||||
}
|
||||
|
||||
public bool AutoIgnorePreviouslyDownloadedEpisodes
|
||||
public bool AutoUnmonitorPreviouslyDownloadedEpisodes
|
||||
{
|
||||
get { return GetValueBoolean("AutoIgnorePreviouslyDownloadedEpisodes"); }
|
||||
set { SetValue("AutoIgnorePreviouslyDownloadedEpisodes", value); }
|
||||
get { return GetValueBoolean("AutoUnmonitorPreviouslyDownloadedEpisodes"); }
|
||||
set { SetValue("AutoUnmonitorPreviouslyDownloadedEpisodes", value); }
|
||||
}
|
||||
|
||||
public int Retention
|
||||
|
@ -22,7 +22,7 @@ public interface IConfigService
|
||||
String DownloadedEpisodesFolder { get; set; }
|
||||
bool UseSeasonFolder { get; set; }
|
||||
string SeasonFolderFormat { get; set; }
|
||||
bool AutoIgnorePreviouslyDownloadedEpisodes { get; set; }
|
||||
bool AutoUnmonitorPreviouslyDownloadedEpisodes { get; set; }
|
||||
int Retention { get; set; }
|
||||
Guid UGuid { get; }
|
||||
DownloadClientType DownloadClient { get; set; }
|
||||
|
22
NzbDrone.Core/Datastore/Migration/010_add_monitored.cs
Normal file
22
NzbDrone.Core/Datastore/Migration/010_add_monitored.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Tags("")]
|
||||
[Migration(10)]
|
||||
public class add_monitored : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
Alter.Table("Episodes").AddColumn("Monitored").AsBoolean().Nullable();
|
||||
Alter.Table("Seasons").AddColumn("Monitored").AsBoolean().Nullable();
|
||||
|
||||
Execute.Sql("UPDATE Episodes SET Monitored = 1 WHERE Ignored = 0");
|
||||
Execute.Sql("UPDATE Episodes SET Monitored = 0 WHERE Ignored = 1");
|
||||
|
||||
Execute.Sql("UPDATE Seasons SET Monitored = 1 WHERE Ignored = 0");
|
||||
Execute.Sql("UPDATE Seasons SET Monitored = 0 WHERE Ignored = 1");
|
||||
}
|
||||
}
|
||||
}
|
16
NzbDrone.Core/Datastore/Migration/011_remove_ignored.cs
Normal file
16
NzbDrone.Core/Datastore/Migration/011_remove_ignored.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using FluentMigrator;
|
||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||
|
||||
namespace NzbDrone.Core.Datastore.Migration
|
||||
{
|
||||
[Tags("")]
|
||||
[Migration(11)]
|
||||
public class remove_ignored : NzbDroneMigrationBase
|
||||
{
|
||||
protected override void MainDbUpgrade()
|
||||
{
|
||||
SQLiteAlter.DropColumns("Episodes", new[] { "Ignored" });
|
||||
SQLiteAlter.DropColumns("Seasons", new[] { "Ignored" });
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@ public string RejectionReason
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Series is not monitored or Episode is ignored";
|
||||
return "Series or Episode is not monitored";
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,12 +30,12 @@ public virtual bool IsSatisfiedBy(RemoteEpisode subject)
|
||||
}
|
||||
|
||||
//return monitored if any of the episodes are monitored
|
||||
if (subject.Episodes.Any(episode => !episode.Ignored))
|
||||
if (subject.Episodes.Any(episode => episode.Monitored))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
_logger.Debug("All episodes are ignored. skipping.");
|
||||
_logger.Debug("No episodes are monitored. skipping.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -214,6 +214,8 @@
|
||||
<Compile Include="Datastore\Migration\007_add_renameEpisodes_to_naming.cs" />
|
||||
<Compile Include="Datastore\Migration\008_remove_backlog.cs" />
|
||||
<Compile Include="Datastore\Migration\009_fix_renameEpisodes.cs" />
|
||||
<Compile Include="Datastore\Migration\010_add_monitored.cs" />
|
||||
<Compile Include="Datastore\Migration\011_remove_ignored.cs" />
|
||||
<Compile Include="Datastore\Migration\Framework\MigrationContext.cs" />
|
||||
<Compile Include="Datastore\Migration\Framework\MigrationController.cs" />
|
||||
<Compile Include="Datastore\Migration\Framework\MigrationExtension.cs" />
|
||||
|
@ -25,8 +25,8 @@ public List<SeriesStatistics> SeriesStatistics()
|
||||
|
||||
var queryText = @"SELECT
|
||||
SeriesId,
|
||||
SUM(CASE WHEN Ignored = 0 AND Airdate <= @currentDate THEN 1 ELSE 0 END) AS EpisodeCount,
|
||||
SUM(CASE WHEN Ignored = 0 AND Episodes.EpisodeFileId > 0 AND AirDate <= @currentDate THEN 1 ELSE 0 END) as EpisodeFileCount,
|
||||
SUM(CASE WHEN Monitored = 1 AND Airdate <= @currentDate THEN 1 ELSE 0 END) AS EpisodeCount,
|
||||
SUM(CASE WHEN Monitored = 1 AND Episodes.EpisodeFileId > 0 AND AirDate <= @currentDate THEN 1 ELSE 0 END) as EpisodeFileCount,
|
||||
MAX(Episodes.SeasonNumber) as SeasonCount,
|
||||
MIN(CASE WHEN AirDate < @currentDate THEN NULL ELSE AirDate END) as NextAiringString
|
||||
FROM Episodes
|
||||
|
@ -17,7 +17,7 @@ public class Episode : ModelBase
|
||||
public DateTime? AirDate { get; set; }
|
||||
|
||||
public string Overview { get; set; }
|
||||
public Boolean Ignored { get; set; }
|
||||
public Boolean Monitored { get; set; }
|
||||
public Nullable<Int32> AbsoluteEpisodeNumber { get; set; }
|
||||
public int SceneSeasonNumber { get; set; }
|
||||
public int SceneEpisodeNumber { get; set; }
|
||||
|
@ -24,7 +24,7 @@ public interface IEpisodeRepository : IBasicRepository<Episode>
|
||||
Episode FindEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
|
||||
List<Episode> EpisodesWithFiles();
|
||||
List<Episode> EpisodesBetweenDates(DateTime startDate, DateTime endDate);
|
||||
void SetIgnoreFlat(Episode episode, bool ignoreFlag);
|
||||
void SetMonitoredFlat(Episode episode, bool monitored);
|
||||
void SetFileId(int episodeId, int fileId);
|
||||
}
|
||||
|
||||
@ -119,10 +119,10 @@ public List<Episode> EpisodesBetweenDates(DateTime startDate, DateTime endDate)
|
||||
.AndWhere(e => e.AirDate <= endDate).ToList();
|
||||
}
|
||||
|
||||
public void SetIgnoreFlat(Episode episode, bool ignoreFlag)
|
||||
public void SetMonitoredFlat(Episode episode, bool monitored)
|
||||
{
|
||||
episode.Ignored = ignoreFlag;
|
||||
SetFields(episode, p => p.Ignored);
|
||||
episode.Monitored = monitored;
|
||||
SetFields(episode, p => p.Monitored);
|
||||
}
|
||||
|
||||
public void SetFileId(int episodeId, int fileId)
|
||||
|
@ -24,7 +24,7 @@ public interface IEpisodeService
|
||||
List<Episode> EpisodesWithFiles();
|
||||
void UpdateEpisode(Episode episode);
|
||||
List<int> GetEpisodeNumbersBySeason(int seriesId, int seasonNumber);
|
||||
void SetEpisodeIgnore(int episodeId, bool isIgnored);
|
||||
void SetEpisodeMonitored(int episodeId, bool monitored);
|
||||
bool IsFirstOrLastEpisodeOfSeason(int episodeId);
|
||||
void UpdateEpisodes(List<Episode> episodes);
|
||||
List<Episode> EpisodesBetweenDates(DateTime start, DateTime end);
|
||||
@ -123,12 +123,12 @@ public List<int> GetEpisodeNumbersBySeason(int seriesId, int seasonNumber)
|
||||
return GetEpisodesBySeason(seriesId, seasonNumber).Select(c => c.Id).ToList();
|
||||
}
|
||||
|
||||
public void SetEpisodeIgnore(int episodeId, bool isIgnored)
|
||||
public void SetEpisodeMonitored(int episodeId, bool monitored)
|
||||
{
|
||||
var episode = _episodeRepository.Get(episodeId);
|
||||
_episodeRepository.SetIgnoreFlat(episode, isIgnored);
|
||||
_episodeRepository.SetMonitoredFlat(episode, monitored);
|
||||
|
||||
logger.Info("Ignore flag for Episode:{0} was set to {1}", episodeId, isIgnored);
|
||||
logger.Info("Monitored flag for Episode:{0} was set to {1}", episodeId, monitored);
|
||||
}
|
||||
|
||||
public bool IsFirstOrLastEpisodeOfSeason(int episodeId)
|
||||
@ -179,7 +179,7 @@ public void Handle(EpisodeFileDeletedEvent message)
|
||||
{
|
||||
_logger.Trace("Detaching episode {0} from file.", episode.Id);
|
||||
episode.EpisodeFileId = 0;
|
||||
episode.Ignored = _configService.AutoIgnorePreviouslyDownloadedEpisodes;
|
||||
episode.Monitored = _configService.AutoUnmonitorPreviouslyDownloadedEpisodes;
|
||||
UpdateEpisode(episode);
|
||||
}
|
||||
}
|
||||
@ -192,7 +192,5 @@ public void Handle(EpisodeFileAddedEvent message)
|
||||
_logger.Debug("Linking [{0}] > [{1}]", message.EpisodeFile.Path, episode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -116,12 +116,12 @@ private void RefreshEpisodeInfo(Series series, IEnumerable<Episode> remoteEpisod
|
||||
//If it is Episode Zero Ignore it (specials, sneak peeks.)
|
||||
if (episode.EpisodeNumber == 0 && episode.SeasonNumber != 1)
|
||||
{
|
||||
episodeToUpdate.Ignored = true;
|
||||
episodeToUpdate.Monitored = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var season = seasons.FirstOrDefault(c => c.SeasonNumber == episode.SeasonNumber);
|
||||
episodeToUpdate.Ignored = season != null && season.Ignored;
|
||||
episodeToUpdate.Monitored = season != null && season.Monitored;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -9,7 +9,7 @@ public class Season : ModelBase
|
||||
{
|
||||
public int SeriesId { get; set; }
|
||||
public int SeasonNumber { get; set; }
|
||||
public Boolean Ignored { get; set; }
|
||||
public Boolean Monitored { get; set; }
|
||||
|
||||
public List<Episode> Episodes { get; set; }
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public interface ISeasonRepository : IBasicRepository<Season>
|
||||
{
|
||||
IList<int> GetSeasonNumbers(int seriesId);
|
||||
Season Get(int seriesId, int seasonNumber);
|
||||
bool IsIgnored(int seriesId, int seasonNumber);
|
||||
bool IsMonitored(int seriesId, int seasonNumber);
|
||||
List<Season> GetSeasonBySeries(int seriesId);
|
||||
}
|
||||
|
||||
@ -32,13 +32,13 @@ public Season Get(int seriesId, int seasonNumber)
|
||||
return Query.Single(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber);
|
||||
}
|
||||
|
||||
public bool IsIgnored(int seriesId, int seasonNumber)
|
||||
public bool IsMonitored(int seriesId, int seasonNumber)
|
||||
{
|
||||
var season = Query.SingleOrDefault(s => s.SeriesId == seriesId && s.SeasonNumber == seasonNumber);
|
||||
|
||||
if (season == null) return false;
|
||||
if (season == null) return true;
|
||||
|
||||
return season.Ignored;
|
||||
return season.Monitored;
|
||||
}
|
||||
|
||||
public List<Season> GetSeasonBySeries(int seriesId)
|
||||
|
Binary file not shown.
@ -6,7 +6,7 @@
|
||||
|
||||
<div class="controls">
|
||||
<label class="checkbox toggle well">
|
||||
<input type="checkbox" name="autoIgnorePreviouslyDownloadedEpisodes"/>
|
||||
<input type="checkbox" name="autoUnmonitorPreviouslyDownloadedEpisodes"/>
|
||||
<p>
|
||||
<span>Yes</span>
|
||||
<span>No</span>
|
||||
@ -16,7 +16,7 @@
|
||||
</label>
|
||||
|
||||
<span class="help-inline-checkbox">
|
||||
<i class="icon-question-sign" title="Episodes deleted from disk are automatically ignored in NzbDrone"/>
|
||||
<i class="icon-question-sign" title="Episodes deleted from disk are automatically unmonitored in NzbDrone"/>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user