mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-16 11:37:58 +02:00
Fixed: SeasonPass didn't update Series monitored flag if only those were changed.
This commit is contained in:
parent
97cdcb8b19
commit
f7859c8eb5
@ -66,6 +66,18 @@ private void GivenSpecials()
|
|||||||
_series.Seasons = new List<Season>{new Season { Monitored = false, SeasonNumber = 0 }};
|
_series.Seasons = new List<Season>{new Season { Monitored = false, SeasonNumber = 0 }};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_be_able_to_monitor_series_without_changing_episodes()
|
||||||
|
{
|
||||||
|
Subject.SetEpisodeMonitoredStatus(_series, null);
|
||||||
|
|
||||||
|
Mocker.GetMock<ISeriesService>()
|
||||||
|
.Verify(v => v.UpdateSeries(It.IsAny<Series>()), Times.Once());
|
||||||
|
|
||||||
|
Mocker.GetMock<IEpisodeService>()
|
||||||
|
.Verify(v => v.UpdateEpisodes(It.IsAny<List<Episode>>()), Times.Never());
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_be_able_to_monitor_all_episodes()
|
public void should_be_able_to_monitor_all_episodes()
|
||||||
{
|
{
|
||||||
|
@ -26,72 +26,76 @@ public EpisodeMonitoredService(ISeriesService seriesService, IEpisodeService epi
|
|||||||
|
|
||||||
public void SetEpisodeMonitoredStatus(Series series, MonitoringOptions monitoringOptions)
|
public void SetEpisodeMonitoredStatus(Series series, MonitoringOptions monitoringOptions)
|
||||||
{
|
{
|
||||||
_logger.Debug("[{0}] Setting episode monitored status.", series.Title);
|
if (monitoringOptions != null)
|
||||||
|
|
||||||
var episodes = _episodeService.GetEpisodeBySeries(series.Id);
|
|
||||||
|
|
||||||
if (monitoringOptions.IgnoreEpisodesWithFiles)
|
|
||||||
{
|
{
|
||||||
_logger.Debug("Ignoring Episodes with Files");
|
_logger.Debug("[{0}] Setting episode monitored status.", series.Title);
|
||||||
ToggleEpisodesMonitoredState(episodes.Where(e => e.HasFile), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
var episodes = _episodeService.GetEpisodeBySeries(series.Id);
|
||||||
{
|
|
||||||
_logger.Debug("Monitoring Episodes with Files");
|
|
||||||
ToggleEpisodesMonitoredState(episodes.Where(e => e.HasFile), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (monitoringOptions.IgnoreEpisodesWithoutFiles)
|
if (monitoringOptions.IgnoreEpisodesWithFiles)
|
||||||
{
|
|
||||||
_logger.Debug("Ignoring Episodes without Files");
|
|
||||||
ToggleEpisodesMonitoredState(episodes.Where(e => !e.HasFile && e.AirDateUtc.HasValue && e.AirDateUtc.Value.Before(DateTime.UtcNow)), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_logger.Debug("Monitoring Episodes without Files");
|
|
||||||
ToggleEpisodesMonitoredState(episodes.Where(e => !e.HasFile && e.AirDateUtc.HasValue && e.AirDateUtc.Value.Before(DateTime.UtcNow)), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
var lastSeason = series.Seasons.Select(s => s.SeasonNumber).MaxOrDefault();
|
|
||||||
|
|
||||||
foreach (var s in series.Seasons)
|
|
||||||
{
|
|
||||||
var season = s;
|
|
||||||
|
|
||||||
if (season.Monitored)
|
|
||||||
{
|
{
|
||||||
if (!monitoringOptions.IgnoreEpisodesWithFiles && !monitoringOptions.IgnoreEpisodesWithoutFiles)
|
_logger.Debug("Ignoring Episodes with Files");
|
||||||
{
|
ToggleEpisodesMonitoredState(episodes.Where(e => e.HasFile), false);
|
||||||
ToggleEpisodesMonitoredState(episodes.Where(e => e.SeasonNumber == season.SeasonNumber), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!monitoringOptions.IgnoreEpisodesWithFiles && !monitoringOptions.IgnoreEpisodesWithoutFiles)
|
_logger.Debug("Monitoring Episodes with Files");
|
||||||
{
|
ToggleEpisodesMonitoredState(episodes.Where(e => e.HasFile), true);
|
||||||
ToggleEpisodesMonitoredState(episodes.Where(e => e.SeasonNumber == season.SeasonNumber), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (season.SeasonNumber == 0)
|
|
||||||
{
|
|
||||||
ToggleEpisodesMonitoredState(episodes.Where(e => e.SeasonNumber == season.SeasonNumber), false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (season.SeasonNumber < lastSeason)
|
if (monitoringOptions.IgnoreEpisodesWithoutFiles)
|
||||||
{
|
{
|
||||||
if (episodes.Where(e => e.SeasonNumber == season.SeasonNumber).All(e => !e.Monitored))
|
_logger.Debug("Ignoring Episodes without Files");
|
||||||
|
ToggleEpisodesMonitoredState(episodes.Where(e => !e.HasFile && e.AirDateUtc.HasValue && e.AirDateUtc.Value.Before(DateTime.UtcNow)), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.Debug("Monitoring Episodes without Files");
|
||||||
|
ToggleEpisodesMonitoredState(episodes.Where(e => !e.HasFile && e.AirDateUtc.HasValue && e.AirDateUtc.Value.Before(DateTime.UtcNow)), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
var lastSeason = series.Seasons.Select(s => s.SeasonNumber).MaxOrDefault();
|
||||||
|
|
||||||
|
foreach (var s in series.Seasons)
|
||||||
|
{
|
||||||
|
var season = s;
|
||||||
|
|
||||||
|
if (season.Monitored)
|
||||||
{
|
{
|
||||||
season.Monitored = false;
|
if (!monitoringOptions.IgnoreEpisodesWithFiles && !monitoringOptions.IgnoreEpisodesWithoutFiles)
|
||||||
|
{
|
||||||
|
ToggleEpisodesMonitoredState(episodes.Where(e => e.SeasonNumber == season.SeasonNumber), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!monitoringOptions.IgnoreEpisodesWithFiles && !monitoringOptions.IgnoreEpisodesWithoutFiles)
|
||||||
|
{
|
||||||
|
ToggleEpisodesMonitoredState(episodes.Where(e => e.SeasonNumber == season.SeasonNumber), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (season.SeasonNumber == 0)
|
||||||
|
{
|
||||||
|
ToggleEpisodesMonitoredState(episodes.Where(e => e.SeasonNumber == season.SeasonNumber), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (season.SeasonNumber < lastSeason)
|
||||||
|
{
|
||||||
|
if (episodes.Where(e => e.SeasonNumber == season.SeasonNumber).All(e => !e.Monitored))
|
||||||
|
{
|
||||||
|
season.Monitored = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_episodeService.UpdateEpisodes(episodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
_seriesService.UpdateSeries(series);
|
_seriesService.UpdateSeries(series);
|
||||||
_episodeService.UpdateEpisodes(episodes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ToggleEpisodesMonitoredState(IEnumerable<Episode> episodes, bool monitored)
|
private void ToggleEpisodesMonitoredState(IEnumerable<Episode> episodes, bool monitored)
|
||||||
|
Loading…
Reference in New Issue
Block a user