From 15aedfc847c85f6dac64b44bb79e1cc0e44fdcde Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 7 Jul 2011 20:27:11 -0700 Subject: [PATCH] some db/migration cleanup --- NzbDrone.Core.Test/IndexerTests.cs | 10 ++--- .../Datastore/Migrations/Migration20110705.cs | 32 --------------- ...ration20110622.cs => Migration20110707.cs} | 24 +++++------ NzbDrone.Core/NzbDrone.Core.csproj | 7 ++-- NzbDrone.Core/Providers/IndexerProvider.cs | 22 +++++----- NzbDrone.Core/Providers/Jobs/JobProvider.cs | 22 +++++----- ...IndexerSetting.cs => IndexerDefinition.cs} | 4 +- .../{JobSetting.cs => JobDefinition.cs} | 4 +- .../Controllers/AddSeriesController.cs | 11 ++--- NzbDrone.Web/Views/AddSeries/AddNew.cshtml | 25 ++++------- NzbDrone.Web/Views/AddSeries/Index.cshtml | 41 ++++++++----------- NzbDrone.Web/Views/System/Indexers.cshtml | 2 +- NzbDrone.Web/Views/System/Jobs.cshtml | 2 +- 13 files changed, 76 insertions(+), 130 deletions(-) delete mode 100644 NzbDrone.Core/Datastore/Migrations/Migration20110705.cs rename NzbDrone.Core/Datastore/Migrations/{Migration20110622.cs => Migration20110707.cs} (95%) rename NzbDrone.Core/Repository/{IndexerSetting.cs => IndexerDefinition.cs} (80%) rename NzbDrone.Core/Repository/{JobSetting.cs => JobDefinition.cs} (87%) diff --git a/NzbDrone.Core.Test/IndexerTests.cs b/NzbDrone.Core.Test/IndexerTests.cs index 92448807c..5392c6e96 100644 --- a/NzbDrone.Core.Test/IndexerTests.cs +++ b/NzbDrone.Core.Test/IndexerTests.cs @@ -35,7 +35,7 @@ namespace NzbDrone.Core.Test .Setup(h => h.DownloadStream(It.IsAny(), It.IsAny())) .Returns(File.OpenRead(".\\Files\\Rss\\" + fileName)); - var fakeSettings = Builder.CreateNew().Build(); + var fakeSettings = Builder.CreateNew().Build(); mocker.GetMock() .Setup(c => c.GetSettings(It.IsAny())) .Returns(fakeSettings); @@ -62,7 +62,7 @@ namespace NzbDrone.Core.Test { var mocker = new AutoMoqer(); mocker.Resolve(); - var fakeSettings = Builder.CreateNew().Build(); + var fakeSettings = Builder.CreateNew().Build(); mocker.GetMock() .Setup(c => c.GetSettings(It.IsAny())) .Returns(fakeSettings); @@ -100,7 +100,7 @@ namespace NzbDrone.Core.Test const string summary = "My fake summary"; - var fakeSettings = Builder.CreateNew().Build(); + var fakeSettings = Builder.CreateNew().Build(); mocker.GetMock() .Setup(c => c.GetSettings(It.IsAny())) .Returns(fakeSettings); @@ -127,7 +127,7 @@ namespace NzbDrone.Core.Test const string summary = "My fake summary"; - var fakeSettings = Builder.CreateNew().Build(); + var fakeSettings = Builder.CreateNew().Build(); mocker.GetMock() .Setup(c => c.GetSettings(It.IsAny())) .Returns(fakeSettings); @@ -150,7 +150,7 @@ namespace NzbDrone.Core.Test var mocker = new AutoMoqer(); mocker.SetConstant(new HttpProvider()); - var fakeSettings = Builder.CreateNew().Build(); + var fakeSettings = Builder.CreateNew().Build(); mocker.GetMock() .Setup(c => c.GetSettings(It.IsAny())) .Returns(fakeSettings); diff --git a/NzbDrone.Core/Datastore/Migrations/Migration20110705.cs b/NzbDrone.Core/Datastore/Migrations/Migration20110705.cs deleted file mode 100644 index 1bcef53d3..000000000 --- a/NzbDrone.Core/Datastore/Migrations/Migration20110705.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Data; -using Migrator.Framework; - -namespace NzbDrone.Core.Datastore.Migrations -{ - - [Migration(20110705)] - public class Migration20110705 : Migration - { - public override void Up() - { - //Upgrade column size - Database.ChangeColumn("Series", new Column("Overview", DbType.String, 4000, ColumnProperty.Null)); - Database.ChangeColumn("Series", new Column("Path", DbType.String, 4000, ColumnProperty.NotNull)); - - Database.ChangeColumn("Episodes", new Column("Overview", DbType.String, 4000, ColumnProperty.Null)); - - Database.ChangeColumn("EpisodeFiles", new Column("Path", DbType.String, 4000, ColumnProperty.NotNull)); - - Database.ChangeColumn("RootDirs", new Column("Path", DbType.String, 4000, ColumnProperty.NotNull)); - - Database.ChangeColumn("Logs", new Column("Message", DbType.String, 4000, ColumnProperty.NotNull)); - Database.ChangeColumn("Logs", new Column("Exception", DbType.String, 4000, ColumnProperty.Null)); - } - - public override void Down() - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/NzbDrone.Core/Datastore/Migrations/Migration20110622.cs b/NzbDrone.Core/Datastore/Migrations/Migration20110707.cs similarity index 95% rename from NzbDrone.Core/Datastore/Migrations/Migration20110622.cs rename to NzbDrone.Core/Datastore/Migrations/Migration20110707.cs index bb509ce00..9566a0d55 100644 --- a/NzbDrone.Core/Datastore/Migrations/Migration20110622.cs +++ b/NzbDrone.Core/Datastore/Migrations/Migration20110707.cs @@ -5,8 +5,8 @@ using Migrator.Framework; namespace NzbDrone.Core.Datastore.Migrations { - [Migration(20110622)] - public class Migration20110622 : Migration + [Migration(20110707)] + public class Migration20110707 : Migration { public override void Up() { @@ -16,11 +16,11 @@ namespace NzbDrone.Core.Datastore.Migrations new Column("Title", DbType.String, ColumnProperty.Null), new Column("CleanTitle", DbType.String, ColumnProperty.Null), new Column("Status", DbType.String, ColumnProperty.Null), - new Column("Overview", DbType.String, ColumnProperty.Null), + new Column("Overview", DbType.String,4000, ColumnProperty.Null), new Column("AirsDayOfWeek", DbType.Int32, ColumnProperty.Null), new Column("AirTimes", DbType.String, ColumnProperty.Null), new Column("Language", DbType.String, ColumnProperty.Null), - new Column("Path", DbType.String, ColumnProperty.NotNull), + new Column("Path", DbType.String,4000, ColumnProperty.NotNull), new Column("Monitored", DbType.Boolean, ColumnProperty.NotNull), new Column("QualityProfileId", DbType.Int32, ColumnProperty.NotNull), new Column("SeasonFolder", DbType.Boolean, ColumnProperty.NotNull), @@ -35,8 +35,8 @@ namespace NzbDrone.Core.Datastore.Migrations new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull), new Column("SeasonNumber", DbType.Int32, ColumnProperty.NotNull), new Column("EpisodeNumber", DbType.Int32, ColumnProperty.NotNull), - new Column("Title", DbType.String, ColumnProperty.Null), - new Column("Overview", DbType.String, ColumnProperty.Null), + new Column("Title", DbType.String,100, ColumnProperty.Null), + new Column("Overview", DbType.String,4000, ColumnProperty.Null), new Column("Ignored", DbType.Boolean, ColumnProperty.NotNull), new Column("EpisodeFileId", DbType.Int32, ColumnProperty.Null), new Column("AirDate", DbType.DateTime, ColumnProperty.Null), @@ -61,7 +61,7 @@ namespace NzbDrone.Core.Datastore.Migrations new Column("EpisodeFileId", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity), new Column("SeriesId", DbType.Int32, ColumnProperty.NotNull), - new Column("Path", DbType.String, ColumnProperty.NotNull), + new Column("Path", DbType.String,4000, ColumnProperty.NotNull), new Column("Quality", DbType.Int32, ColumnProperty.NotNull), new Column("Proper", DbType.Int32, ColumnProperty.NotNull), new Column("Size", DbType.Int64, ColumnProperty.NotNull), @@ -107,7 +107,7 @@ namespace NzbDrone.Core.Datastore.Migrations Database.AddTable("RootDirs", new[] { new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity), - new Column("Path", DbType.String, ColumnProperty.NotNull) + new Column("Path", DbType.String, 4000, ColumnProperty.NotNull) }); Database.AddTable("ExternalNotificationSettings", new[] @@ -118,7 +118,7 @@ namespace NzbDrone.Core.Datastore.Migrations new Column("Name", DbType.String, ColumnProperty.NotNull) }); - Database.AddTable("JobSettings", new[] + Database.AddTable("JobDefinitions", new[] { new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity), new Column("Enable", DbType.Boolean, ColumnProperty.NotNull), @@ -140,16 +140,16 @@ namespace NzbDrone.Core.Datastore.Migrations Database.AddTable("Logs", new[] { new Column("LogId", DbType.Int64, ColumnProperty.PrimaryKeyWithIdentity), - new Column("Message", DbType.String, ColumnProperty.NotNull), + new Column("Message", DbType.String,4000, ColumnProperty.NotNull), new Column("Time", DbType.DateTime, ColumnProperty.NotNull), new Column("Logger", DbType.String, ColumnProperty.NotNull), new Column("Method", DbType.String, ColumnProperty.NotNull), - new Column("Exception", DbType.String, ColumnProperty.Null), + new Column("Exception", DbType.String,4000, ColumnProperty.Null), new Column("ExceptionType", DbType.String, ColumnProperty.Null), new Column("Level", DbType.String, ColumnProperty.NotNull) }); - Database.AddTable("IndexerSettings", new[] + Database.AddTable("IndexerDefinitions", new[] { new Column("Id", DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity), new Column("Enable", DbType.Boolean, ColumnProperty.NotNull), diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 0368c892b..6b0b1d83a 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -176,8 +176,7 @@ - - + @@ -215,8 +214,8 @@ - - + + diff --git a/NzbDrone.Core/Providers/IndexerProvider.cs b/NzbDrone.Core/Providers/IndexerProvider.cs index 6bb8a83b9..85eebd11d 100644 --- a/NzbDrone.Core/Providers/IndexerProvider.cs +++ b/NzbDrone.Core/Providers/IndexerProvider.cs @@ -34,28 +34,28 @@ namespace NzbDrone.Core.Providers return _indexers.Where(i => all.Exists(c => c.IndexProviderType == i.GetType().ToString() && c.Enable)).ToList(); } - public virtual List GetAllISettings() + public virtual List GetAllISettings() { - return _database.Fetch(); + return _database.Fetch(); } - public virtual void SaveSettings(IndexerSetting settings) + public virtual void SaveSettings(IndexerDefinition definitions) { - if (settings.Id == 0) + if (definitions.Id == 0) { - Logger.Debug("Adding Indexer settings for {0}", settings.Name); - _database.Insert(settings); + Logger.Debug("Adding Indexer definitions for {0}", definitions.Name); + _database.Insert(definitions); } else { - Logger.Debug("Updating Indexer settings for {0}", settings.Name); - _database.Update(settings); + Logger.Debug("Updating Indexer definitions for {0}", definitions.Name); + _database.Update(definitions); } } - public virtual IndexerSetting GetSettings(Type type) + public virtual IndexerDefinition GetSettings(Type type) { - return _database.Single("WHERE IndexProviderType = @0", type.ToString()); + return _database.Single("WHERE IndexProviderType = @0", type.ToString()); } public virtual void InitializeIndexers(IList indexers) @@ -71,7 +71,7 @@ namespace NzbDrone.Core.Providers IndexerBase indexerLocal = feedProvider; if (!currentIndexers.Exists(c => c.IndexProviderType == indexerLocal.GetType().ToString())) { - var settings = new IndexerSetting + var settings = new IndexerDefinition { Enable = false, IndexProviderType = indexerLocal.GetType().ToString(), diff --git a/NzbDrone.Core/Providers/Jobs/JobProvider.cs b/NzbDrone.Core/Providers/Jobs/JobProvider.cs index efb8012c4..7e83f720e 100644 --- a/NzbDrone.Core/Providers/Jobs/JobProvider.cs +++ b/NzbDrone.Core/Providers/Jobs/JobProvider.cs @@ -40,26 +40,26 @@ namespace NzbDrone.Core.Providers.Jobs /// Returns a list of all registered jobs /// /// - public virtual List All() + public virtual List All() { - return _database.Fetch().ToList(); + return _database.Fetch().ToList(); } /// - /// Creates/Updates settings for a job + /// Creates/Updates definitions for a job /// - /// Settings to be created/updated - public virtual void SaveSettings(JobSetting settings) + /// Settings to be created/updated + public virtual void SaveSettings(JobDefinition definitions) { - if (settings.Id == 0) + if (definitions.Id == 0) { - Logger.Trace("Adding job settings for {0}", settings.Name); - _database.Insert(settings); + Logger.Trace("Adding job definitions for {0}", definitions.Name); + _database.Insert(definitions); } else { - Logger.Trace("Updating job settings for {0}", settings.Name); - _database.Update(settings); + Logger.Trace("Updating job definitions for {0}", definitions.Name); + _database.Update(definitions); } } @@ -286,7 +286,7 @@ namespace NzbDrone.Core.Providers.Jobs var timerProviderLocal = timer; if (!currentTimer.Exists(c => c.TypeName == timerProviderLocal.GetType().ToString())) { - var settings = new JobSetting + var settings = new JobDefinition { Enable = timerProviderLocal.DefaultInterval > 0, TypeName = timer.GetType().ToString(), diff --git a/NzbDrone.Core/Repository/IndexerSetting.cs b/NzbDrone.Core/Repository/IndexerDefinition.cs similarity index 80% rename from NzbDrone.Core/Repository/IndexerSetting.cs rename to NzbDrone.Core/Repository/IndexerDefinition.cs index b1a8ad1be..f32879cc7 100644 --- a/NzbDrone.Core/Repository/IndexerSetting.cs +++ b/NzbDrone.Core/Repository/IndexerDefinition.cs @@ -3,9 +3,9 @@ using PetaPoco; namespace NzbDrone.Core.Repository { - [TableName("IndexerSettings")] + [TableName("IndexerDefinitions")] [PrimaryKey("Id", autoIncrement = true)] - public class IndexerSetting + public class IndexerDefinition { public int Id { get; set; } diff --git a/NzbDrone.Core/Repository/JobSetting.cs b/NzbDrone.Core/Repository/JobDefinition.cs similarity index 87% rename from NzbDrone.Core/Repository/JobSetting.cs rename to NzbDrone.Core/Repository/JobDefinition.cs index 1ab02fff7..3eb1dcec9 100644 --- a/NzbDrone.Core/Repository/JobSetting.cs +++ b/NzbDrone.Core/Repository/JobDefinition.cs @@ -3,9 +3,9 @@ using PetaPoco; namespace NzbDrone.Core.Repository { - [TableName("JobSettings")] + [TableName("JobDefinitions")] [PrimaryKey("Id", autoIncrement = true)] - public class JobSetting + public class JobDefinition { public Int32 Id { get; set; } diff --git a/NzbDrone.Web/Controllers/AddSeriesController.cs b/NzbDrone.Web/Controllers/AddSeriesController.cs index 5916152fb..5e9769eb5 100644 --- a/NzbDrone.Web/Controllers/AddSeriesController.cs +++ b/NzbDrone.Web/Controllers/AddSeriesController.cs @@ -49,18 +49,13 @@ namespace NzbDrone.Web.Controllers public ActionResult AddNew() { - var rootDirs = _rootFolderProvider.GetAll().Select(r => - new RootDirModel - { - Path = r.Path, - CleanPath = r.Path.Replace(Path.DirectorySeparatorChar, '|').Replace(Path.VolumeSeparatorChar, '^').Replace('\'', '`') - }); - ViewData["RootDirs"] = rootDirs.ToList(); - ViewData["DirSep"] = Path.DirectorySeparatorChar.ToString().Replace(Path.DirectorySeparatorChar, '|'); + ViewData["RootDirs"] = _rootFolderProvider.GetAll().Select(c => c.Path).OrderBy(e => e).ToList(); var defaultQuality = _configProvider.DefaultQualityProfile; var qualityProfiles = _qualityProvider.GetAllProfiles(); + ViewData["qualityList"] = qualityProfiles; + ViewData["quality"] = new SelectList( qualityProfiles, "QualityProfileId", diff --git a/NzbDrone.Web/Views/AddSeries/AddNew.cshtml b/NzbDrone.Web/Views/AddSeries/AddNew.cshtml index 0944f372c..124afee72 100644 --- a/NzbDrone.Web/Views/AddSeries/AddNew.cshtml +++ b/NzbDrone.Web/Views/AddSeries/AddNew.cshtml @@ -1,22 +1,11 @@ -@using NzbDrone.Web.Models -@{ - Layout = null; -} +@using System.Collections +@using NzbDrone.Web.Models +@{ Layout = null; }
-
- Root Directory - @{int d = 0; - - foreach (var dir in ViewData["RootDirs"] as List) - { -
- @Html.RadioButton("selectedRootDir", dir.CleanPath, d == 0, new { @class = "dirList examplePart", id = "dirRadio_" + d }) - @Html.Label(dir.Path) - @{ d++; } -
- } - } -
+ @Html.Label("Root Directory") + @Html.DropDownList("rootDirList", new SelectList((IList)ViewData["RootDirs"])) + @Html.Label("Quality") + @Html.DropDownList("qualityList", new SelectList((IList)ViewData["QualityList"], "QualityProfileId", "Name"))

diff --git a/NzbDrone.Web/Views/AddSeries/Index.cshtml b/NzbDrone.Web/Views/AddSeries/Index.cshtml index aab13e9f5..7d4022af2 100644 --- a/NzbDrone.Web/Views/AddSeries/Index.cshtml +++ b/NzbDrone.Web/Views/AddSeries/Index.cshtml @@ -1,45 +1,40 @@ @model List @using NzbDrone.Core.Repository - @section HeaderContent { } - @section TitleContent{ Add Series } @section MainContent{ - @{ Html.Telerik().Window() - .Name("Window") - .Title("Add New Series") - .Modal(true) - .Buttons(b => b.Close()) - .Width(500) - .Height(200) - .Visible(false) - .Draggable(true) - .Resizable(resizing => resizing.Enabled(false)) - .LoadContentFrom("AddNew", "AddSeries") - .Render(); - } -
- - @Html.Telerik().DropDownList().Name("masterDropbox").BindTo((SelectList)ViewData["qualities"]).HtmlAttributes( - new { style = "width: 100px; margin-left:224px;" }).ClientEvents(events => events.OnChange("masterChanged")) +
+ @{ Html.RenderAction("AddNew", "AddSeries"); }
- @{Html.RenderAction("RootDir");}
+
+ + @Html.Telerik().DropDownList().Name("masterDropbox").BindTo((SelectList)ViewData["qualities"]).HtmlAttributes( + new { style = "width: 100px; margin-left:224px;" }).ClientEvents(events => events.OnChange("masterChanged")) +
@{ Html.RenderAction("AddExisting", "AddSeries"); }
} - - @section Scripts {