BacklogSetting refactoring.

pull/7/merge
Mark McDowall 13 years ago
parent 3a5d99921e
commit 02cb12bdb8

@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test.JobTests
var series = Builder<Series>.CreateNew()
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(1)
@ -93,7 +93,7 @@ namespace NzbDrone.Core.Test.JobTests
var series = Builder<Series>.CreateNew()
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(5)
@ -129,7 +129,7 @@ namespace NzbDrone.Core.Test.JobTests
var series = Builder<Series>.CreateNew()
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(5)
@ -169,7 +169,7 @@ namespace NzbDrone.Core.Test.JobTests
var series = Builder<Series>.CreateNew()
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(5)
@ -210,12 +210,12 @@ namespace NzbDrone.Core.Test.JobTests
var series = Builder<Series>.CreateNew()
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.Build();
var series2 = Builder<Series>.CreateNew()
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(10)
@ -260,10 +260,10 @@ namespace NzbDrone.Core.Test.JobTests
var series = Builder<Series>.CreateListOfSize(2)
.TheFirst(1)
.With(s => s.Monitored = false)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.TheNext(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(11)
@ -295,13 +295,13 @@ namespace NzbDrone.Core.Test.JobTests
var series = Builder<Series>.CreateListOfSize(3)
.TheFirst(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Disable)
.With(s => s.BacklogSetting = BacklogSettingType.Disable)
.TheNext(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.TheNext(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Inherit)
.With(s => s.BacklogSetting = BacklogSettingType.Inherit)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(12)
@ -323,9 +323,9 @@ namespace NzbDrone.Core.Test.JobTests
//Assert
result.Should().NotBeEmpty();
result.Should().Contain(s => s.Series.BacklogStatus == BacklogStatusType.Enable);
result.Should().NotContain(s => s.Series.BacklogStatus == BacklogStatusType.Disable);
result.Should().NotContain(s => s.Series.BacklogStatus == BacklogStatusType.Inherit);
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Enable);
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Disable);
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Inherit);
}
[Test]
@ -335,13 +335,13 @@ namespace NzbDrone.Core.Test.JobTests
var series = Builder<Series>.CreateListOfSize(3)
.TheFirst(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Disable)
.With(s => s.BacklogSetting = BacklogSettingType.Disable)
.TheNext(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.TheNext(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Inherit)
.With(s => s.BacklogSetting = BacklogSettingType.Inherit)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(12)
@ -363,9 +363,9 @@ namespace NzbDrone.Core.Test.JobTests
//Assert
result.Should().NotBeEmpty();
result.Should().Contain(s => s.Series.BacklogStatus == BacklogStatusType.Enable);
result.Should().NotContain(s => s.Series.BacklogStatus == BacklogStatusType.Disable);
result.Should().Contain(s => s.Series.BacklogStatus == BacklogStatusType.Inherit);
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Enable);
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Disable);
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Inherit);
}
}
}

@ -55,7 +55,7 @@ namespace NzbDrone.Core.Test.JobTests
var series = Builder<Series>.CreateNew()
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.Build();
//Setup
@ -104,10 +104,10 @@ namespace NzbDrone.Core.Test.JobTests
var series = Builder<Series>.CreateListOfSize(2)
.TheFirst(1)
.With(s => s.Monitored = false)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.TheNext(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(11)
@ -139,13 +139,13 @@ namespace NzbDrone.Core.Test.JobTests
var series = Builder<Series>.CreateListOfSize(3)
.TheFirst(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Disable)
.With(s => s.BacklogSetting = BacklogSettingType.Disable)
.TheNext(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.TheNext(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Inherit)
.With(s => s.BacklogSetting = BacklogSettingType.Inherit)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(12)
@ -167,9 +167,9 @@ namespace NzbDrone.Core.Test.JobTests
//Assert
result.Should().NotBeEmpty();
result.Should().Contain(s => s.Series.BacklogStatus == BacklogStatusType.Enable);
result.Should().NotContain(s => s.Series.BacklogStatus == BacklogStatusType.Disable);
result.Should().NotContain(s => s.Series.BacklogStatus == BacklogStatusType.Inherit);
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Enable);
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Disable);
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Inherit);
}
[Test]
@ -179,13 +179,13 @@ namespace NzbDrone.Core.Test.JobTests
var series = Builder<Series>.CreateListOfSize(3)
.TheFirst(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Disable)
.With(s => s.BacklogSetting = BacklogSettingType.Disable)
.TheNext(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Enable)
.With(s => s.BacklogSetting = BacklogSettingType.Enable)
.TheNext(1)
.With(s => s.Monitored = true)
.With(s => s.BacklogStatus = BacklogStatusType.Inherit)
.With(s => s.BacklogSetting = BacklogSettingType.Inherit)
.Build();
var episodes = Builder<Episode>.CreateListOfSize(12)
@ -207,9 +207,9 @@ namespace NzbDrone.Core.Test.JobTests
//Assert
result.Should().NotBeEmpty();
result.Should().Contain(s => s.Series.BacklogStatus == BacklogStatusType.Enable);
result.Should().NotContain(s => s.Series.BacklogStatus == BacklogStatusType.Disable);
result.Should().Contain(s => s.Series.BacklogStatus == BacklogStatusType.Inherit);
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Enable);
result.Should().NotContain(s => s.Series.BacklogSetting == BacklogSettingType.Disable);
result.Should().Contain(s => s.Series.BacklogSetting == BacklogSettingType.Inherit);
}
}

@ -8,8 +8,7 @@ namespace NzbDrone.Core.Datastore.Migrations
{
protected override void MainDbUpgrade()
{
Database.AddColumn("Series", "BacklogStatus", DbType.Int32, ColumnProperty.Null);
Database.ExecuteNonQuery("UPDATE Series SET BacklogStatus = 2");
Database.AddColumn("Series", "BacklogSetting", DbType.Int32, ColumnProperty.Null);
}
}
}

@ -92,7 +92,7 @@ namespace NzbDrone.Core.Jobs
{
Logger.Trace("Backlog searching is not enabled, only running for explicitly enabled series.");
return _episodeProvider.EpisodesWithoutFiles(true).Where(e =>
e.Series.BacklogStatus == BacklogStatusType.Enable &&
e.Series.BacklogSetting == BacklogSettingType.Enable &&
e.Series.Monitored
).ToList();
}
@ -101,7 +101,7 @@ namespace NzbDrone.Core.Jobs
{
Logger.Trace("Backlog searching is enabled, skipping explicity disabled series.");
return _episodeProvider.EpisodesWithoutFiles(true).Where(e =>
e.Series.BacklogStatus != BacklogStatusType.Disable &&
e.Series.BacklogSetting != BacklogSettingType.Disable &&
e.Series.Monitored
).ToList();
}

@ -54,7 +54,7 @@ namespace NzbDrone.Core.Jobs
Logger.Trace("Backlog searching is not enabled, only running for explicitly enabled series.");
return _episodeProvider.EpisodesWithoutFiles(true).Where(e =>
e.AirDate >= DateTime.Today.AddDays(-30) &&
e.Series.BacklogStatus == BacklogStatusType.Enable &&
e.Series.BacklogSetting == BacklogSettingType.Enable &&
e.Series.Monitored
).ToList();
}
@ -64,7 +64,7 @@ namespace NzbDrone.Core.Jobs
Logger.Trace("Backlog searching is enabled, skipping explicity disabled series.");
return _episodeProvider.EpisodesWithoutFiles(true).Where(e =>
e.AirDate >= DateTime.Today.AddDays(-30) &&
e.Series.BacklogStatus != BacklogStatusType.Disable &&
e.Series.BacklogSetting != BacklogSettingType.Disable &&
e.Series.Monitored
).ToList();
}

@ -0,0 +1,9 @@
namespace NzbDrone.Core.Model
{
public enum BacklogSettingType
{
Inherit = 0,
Enable = 1,
Disable = 2
}
}

@ -1,9 +0,0 @@
namespace NzbDrone.Core.Model
{
public enum BacklogStatusType
{
Disable = 0,
Enable = 1,
Inherit = 2
}
}

@ -229,7 +229,7 @@
<Compile Include="Datastore\PetaPoco\PetaPoco.cs" />
<Compile Include="Model\AtomicParsleyTitleType.cs" />
<Compile Include="Model\ConnectionInfoModel.cs" />
<Compile Include="Model\BacklogStatusType.cs" />
<Compile Include="Model\BacklogSettingType.cs" />
<Compile Include="Model\PostDownloadStatusType.cs" />
<Compile Include="Model\JobQueueItem.cs" />
<Compile Include="Model\LanguageType.cs" />

@ -46,7 +46,7 @@ namespace NzbDrone.Core.Providers
{
var series = _database
.Fetch<Series, QualityProfile>(@"SELECT Series.SeriesId, Series.Title, Series.CleanTitle, Series.Status, Series.Overview, Series.AirsDayOfWeek,Series.AirTimes,
Series.Language, Series.Path, Series.Monitored, Series.QualityProfileId, Series.SeasonFolder, Series.BacklogStatus,
Series.Language, Series.Path, Series.Monitored, Series.QualityProfileId, Series.SeasonFolder, Series.BacklogSetting,
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 OR Ignored = 1 THEN NULL ELSE AirDate END) as NextAiring,
@ -56,7 +56,7 @@ namespace NzbDrone.Core.Providers
LEFT JOIN Episodes ON Series.SeriesId = Episodes.SeriesId
WHERE Series.LastInfoSync IS NOT NULL
GROUP BY Series.SeriesId, Series.Title, Series.CleanTitle, Series.Status, Series.Overview, Series.AirsDayOfWeek,Series.AirTimes,
Series.Language, Series.Path, Series.Monitored, Series.QualityProfileId, Series.SeasonFolder, Series.BacklogStatus,
Series.Language, Series.Path, Series.Monitored, Series.QualityProfileId, Series.SeasonFolder, Series.BacklogSetting,
QualityProfiles.QualityProfileId, QualityProfiles.Name, QualityProfiles.Cutoff, QualityProfiles.SonicAllowed", DateTime.Today);
return series;
@ -120,7 +120,7 @@ namespace NzbDrone.Core.Providers
repoSeries.QualityProfileId = _configProvider.DefaultQualityProfile;
repoSeries.SeasonFolder = _configProvider.UseSeasonFolder;
repoSeries.BacklogStatus = BacklogStatusType.Inherit;
repoSeries.BacklogSetting = BacklogSettingType.Inherit;
_database.Insert(repoSeries);
}
@ -212,7 +212,7 @@ namespace NzbDrone.Core.Providers
series.QualityProfileId = edited.QualityProfileId;
series.Monitored = edited.Monitored;
series.SeasonFolder = edited.SeasonFolder;
series.BacklogStatus = edited.BacklogStatus;
series.BacklogSetting = edited.BacklogSetting;
series.Path = edited.Path;
}

@ -44,7 +44,7 @@ namespace NzbDrone.Core.Repository
public bool IsDaily { get; set; }
public BacklogStatusType BacklogStatus { get; set; }
public BacklogSettingType BacklogSetting { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this <see cref="Series"/> is hidden.

@ -51,12 +51,12 @@ namespace NzbDrone.Web.Controllers
var backlogStatusTypes = new List<KeyValuePair<int, string>>();
foreach (BacklogStatusType backlogStatusType in Enum.GetValues(typeof(BacklogStatusType)))
foreach (BacklogSettingType backlogStatusType in Enum.GetValues(typeof(BacklogSettingType)))
{
backlogStatusTypes.Add(new KeyValuePair<int, string>((int)backlogStatusType, backlogStatusType.ToString()));
}
ViewData["BacklogStatusSelectList"] = new SelectList(backlogStatusTypes, "Key", "Value");
ViewData["BacklogSettingSelectList"] = new SelectList(backlogStatusTypes, "Key", "Value");
return View();
}
@ -70,14 +70,14 @@ namespace NzbDrone.Web.Controllers
[AcceptVerbs(HttpVerbs.Post)]
[GridAction]
public ActionResult _SaveAjaxSeriesEditing(int id, string path, bool monitored, bool seasonFolder, int qualityProfileId, int backlogStatus)
public ActionResult _SaveAjaxSeriesEditing(int id, string path, bool monitored, bool seasonFolder, int qualityProfileId, int backlogSetting)
{
var oldSeries = _seriesProvider.GetSeries(id);
oldSeries.Monitored = monitored;
oldSeries.SeasonFolder = seasonFolder;
oldSeries.QualityProfileId = qualityProfileId;
oldSeries.Path = path;
oldSeries.BacklogStatus = (BacklogStatusType)backlogStatus;
oldSeries.BacklogSetting = (BacklogSettingType)backlogSetting;
_seriesProvider.UpdateSeries(oldSeries);
@ -179,18 +179,18 @@ namespace NzbDrone.Web.Controllers
}, "Key", "Value"
);
var backlogStatusTypes = new List<KeyValuePair<int, string>>();
var backlogSettingTypes = new List<KeyValuePair<int, string>>();
foreach (BacklogStatusType backlogStatusType in Enum.GetValues(typeof(BacklogStatusType)))
foreach (BacklogSettingType backlogSettingType in Enum.GetValues(typeof(BacklogSettingType)))
{
backlogStatusTypes.Add(new KeyValuePair<int, string>((int)backlogStatusType, backlogStatusType.ToString()));
backlogSettingTypes.Add(new KeyValuePair<int, string>((int)backlogSettingType, backlogSettingType.ToString()));
}
ViewData["BacklogStatusTypes"] = backlogStatusTypes;
ViewData["BacklogSettingTypes"] = backlogSettingTypes;
var masterBacklogList = backlogStatusTypes.ToList();
var masterBacklogList = backlogSettingTypes.ToList();
masterBacklogList.Insert(0, new KeyValuePair<int, string>(-10, "Unchanged"));
ViewData["MasterBacklogStatusSelectList"] = new SelectList(masterBacklogList, "Key", "Value");
ViewData["MasterBacklogSettingSelectList"] = new SelectList(masterBacklogList, "Key", "Value");
var series = _seriesProvider.GetAllSeries().OrderBy(o => SortHelper.SkipArticles(o.Title));
@ -221,7 +221,7 @@ namespace NzbDrone.Web.Controllers
QualityProfileId = s.QualityProfileId,
QualityProfileName = s.QualityProfile.Name,
SeasonFolder = s.SeasonFolder,
BacklogStatus = (int)s.BacklogStatus,
BacklogSetting = (int)s.BacklogSetting,
Status = s.Status,
SeasonsCount = s.SeasonCount,
EpisodeCount = s.EpisodeCount,

@ -44,8 +44,8 @@ namespace NzbDrone.Web.Models
[Description("Should NzbDrone download episodes for this series?")]
public bool Monitored { get; set; }
[DisplayName("Backlog Status")]
[DisplayName("Backlog Setting")]
[Description("Should NzbDrone download past missing episodes?")]
public int BacklogStatus { get; set; }
public int BacklogSetting { get; set; }
}
}

@ -30,9 +30,9 @@
<span class="small">@Html.DescriptionFor(m => m.Path)</span>
</label>
@Html.TextBoxFor(m => m.Path, new { @class = "inputClass" })
<label class="labelClass">@Html.LabelFor(m => m.BacklogStatus)
<span class="small">@Html.DescriptionFor(m => m.BacklogStatus)</span>
<label class="labelClass">@Html.LabelFor(m => m.BacklogSetting)
<span class="small">@Html.DescriptionFor(m => m.BacklogSetting)</span>
</label>
@Html.DropDownListFor(m => m.BacklogStatus, (SelectList)ViewData["BacklogStatusSelectList"], new { @class = "inputClass" })
@Html.DropDownListFor(m => m.BacklogSetting, (SelectList)ViewData["BacklogSettingSelectList"], new { @class = "inputClass" })
</div>
</div>

@ -99,7 +99,7 @@
<label class="labelClass">Backlog Status
<span class="small">Should NzbDrone perform backlog searches for this series?</span>
</label>
@Html.DropDownList("masterBacklogStatus", (SelectList)ViewData["MasterBacklogStatusSelectList"], new { @class = "inputClass" })
@Html.DropDownList("masterBacklogSetting", (SelectList)ViewData["MasterBacklogSettingSelectList"], new { @class = "inputClass" })
</div>
</div>
</div>
@ -127,7 +127,7 @@
var profileId = $('#masterQualitySelector').val();
var monitored = $('#masterMonitored').val();
var seasonFolder = $('#masterSeasonFolder').val();
var backlogStatus = $('#masterBacklogStatus').val();
var backlogStatus = $('#masterBacklogSetting').val();
var selected = $('.editToggle:checked');
@ -153,7 +153,7 @@
}
if (backlogStatus != -10) {
$(this).parent('td').parent('.seriesEditRow').find('.backlogStatus').val(backlogStatus);
$(this).parent('td').parent('.seriesEditRow').find('.backlogSetting').val(backlogStatus);
}
});

@ -19,7 +19,7 @@
<td>@Html.DropDownListFor(m => m.QualityProfileId, new SelectList((List<QualityProfile>)ViewData["QualityProfiles"], "QualityProfileId", "Name", Model.QualityProfileId), new { @class = "quality" })</td>
<td class="checkboxColumn">@Html.CheckBoxFor(m => m.Monitored, new {@class = "seriesCheckbox monitored"})</td>
<td class="checkboxColumn">@Html.CheckBoxFor(m => m.SeasonFolder, new {@class = "seriesCheckbox seasonFolder"})</td>
<td>@Html.DropDownListFor(m => m.BacklogStatus, new SelectList((List<KeyValuePair<int, string>>)ViewData["BacklogStatusTypes"], "Key", "Value", (int)Model.BacklogStatus), new { @class = "backlogStatus" })</td>
<td>@Html.DropDownListFor(m => m.BacklogSetting, new SelectList((List<KeyValuePair<int, string>>)ViewData["BacklogSettingTypes"], "Key", "Value", (int)Model.BacklogSetting), new { @class = "backlogSetting" })</td>
<td>@Html.TextBoxFor(m => m.Path, new { @class = "path" })</td>
</tr>
}
Loading…
Cancel
Save