From e358ad6d87aa1709e54a49fd85ac2ac723f1f26a Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 14 Jan 2012 18:47:23 -0800 Subject: [PATCH] Jobs now use Timespan rather than integer to represent minutes. --- .../ProviderTests/JobProviderTests/JobProviderFixture.cs | 4 ++-- .../ProviderTests/JobProviderTests/TestJobs.cs | 8 ++++---- NzbDrone.Core/Jobs/AppUpdateJob.cs | 7 ++++--- NzbDrone.Core/Jobs/BacklogSearchJob.cs | 7 ++++--- NzbDrone.Core/Jobs/BannerDownloadJob.cs | 5 ++--- NzbDrone.Core/Jobs/ConvertEpisodeJob.cs | 4 ++-- NzbDrone.Core/Jobs/DeleteSeriesJob.cs | 4 ++-- NzbDrone.Core/Jobs/DiskScanJob.cs | 4 ++-- NzbDrone.Core/Jobs/EpisodeSearchJob.cs | 4 ++-- NzbDrone.Core/Jobs/IJob.cs | 5 +++-- NzbDrone.Core/Jobs/ImportNewSeriesJob.cs | 6 +++--- NzbDrone.Core/Jobs/JobProvider.cs | 4 ++-- NzbDrone.Core/Jobs/PostDownloadScanJob.cs | 4 ++-- NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs | 4 ++-- NzbDrone.Core/Jobs/RenameEpisodeJob.cs | 4 ++-- NzbDrone.Core/Jobs/RenameSeasonJob.cs | 4 ++-- NzbDrone.Core/Jobs/RenameSeriesJob.cs | 4 ++-- NzbDrone.Core/Jobs/RssSyncJob.cs | 4 ++-- NzbDrone.Core/Jobs/SeasonSearchJob.cs | 4 ++-- NzbDrone.Core/Jobs/SeriesSearchJob.cs | 4 ++-- NzbDrone.Core/Jobs/TrimLogsJob.cs | 7 ++++--- NzbDrone.Core/Jobs/UpdateInfoJob.cs | 4 ++-- NzbDrone.Core/Jobs/UpdateSceneMappingsJob.cs | 7 ++++--- NzbDrone.Web/Views/System/Jobs.cshtml | 3 ++- 24 files changed, 60 insertions(+), 55 deletions(-) diff --git a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs index e923c0691..8738c952c 100644 --- a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs +++ b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/JobProviderFixture.cs @@ -250,7 +250,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests //assert var timers = jobProvider.All(); timers.Should().HaveCount(1); - timers[0].Interval.Should().Be(fakeJob.DefaultInterval); + timers[0].Interval.Should().Be((Int32)fakeJob.DefaultInterval.TotalMinutes); timers[0].Name.Should().Be(fakeJob.Name); timers[0].TypeName.Should().Be(fakeJob.GetType().ToString()); timers[0].LastExecution.Should().HaveYear(DateTime.Now.Year); @@ -354,7 +354,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests registeredJobs.Should().HaveCount(1); registeredJobs.First().TypeName.Should().Be(fakeJob.GetType().ToString()); registeredJobs.First().Name.Should().Be(fakeJob.Name); - registeredJobs.First().Interval.Should().Be(fakeJob.DefaultInterval); + registeredJobs.First().Interval.Should().Be((Int32)fakeJob.DefaultInterval.TotalMinutes); registeredJobs.First().Enable.Should().Be(true); registeredJobs.First().Success.Should().Be(initialFakeJob.Success); diff --git a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/TestJobs.cs b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/TestJobs.cs index b4f0bc744..b53d8329b 100644 --- a/NzbDrone.Core.Test/ProviderTests/JobProviderTests/TestJobs.cs +++ b/NzbDrone.Core.Test/ProviderTests/JobProviderTests/TestJobs.cs @@ -14,9 +14,9 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests get { return GetType().Name; } } - public virtual int DefaultInterval + public virtual TimeSpan DefaultInterval { - get { return 15; } + get { return TimeSpan.FromMinutes(15); } } public int ExecutionCount { get; private set; } @@ -36,9 +36,9 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests public class DisabledJob : FakeJob { - public override int DefaultInterval + public override TimeSpan DefaultInterval { - get { return 0; } + get { return TimeSpan.FromTicks(0); } } } diff --git a/NzbDrone.Core/Jobs/AppUpdateJob.cs b/NzbDrone.Core/Jobs/AppUpdateJob.cs index 732f358f8..55b270a6c 100644 --- a/NzbDrone.Core/Jobs/AppUpdateJob.cs +++ b/NzbDrone.Core/Jobs/AppUpdateJob.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using System.Diagnostics; using System.IO; using NLog; @@ -39,9 +40,9 @@ namespace NzbDrone.Core.Jobs get { return "Update Application Job"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 10080; } + get { return TimeSpan.FromDays(2); } } public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/BacklogSearchJob.cs b/NzbDrone.Core/Jobs/BacklogSearchJob.cs index f9f270f90..aca49173a 100644 --- a/NzbDrone.Core/Jobs/BacklogSearchJob.cs +++ b/NzbDrone.Core/Jobs/BacklogSearchJob.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using NLog; using NzbDrone.Core.Model.Notification; @@ -31,9 +32,9 @@ namespace NzbDrone.Core.Jobs get { return "Backlog Search"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 43200; } + get { return TimeSpan.FromDays(30); } } public void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/BannerDownloadJob.cs b/NzbDrone.Core/Jobs/BannerDownloadJob.cs index 38edbf5bc..23b357abc 100644 --- a/NzbDrone.Core/Jobs/BannerDownloadJob.cs +++ b/NzbDrone.Core/Jobs/BannerDownloadJob.cs @@ -40,10 +40,9 @@ namespace NzbDrone.Core.Jobs get { return "Banner Download"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - //30 days - get { return 43200; } + get { return TimeSpan.FromDays(30); } } public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/ConvertEpisodeJob.cs b/NzbDrone.Core/Jobs/ConvertEpisodeJob.cs index 4fc94e0e7..08fe467e0 100644 --- a/NzbDrone.Core/Jobs/ConvertEpisodeJob.cs +++ b/NzbDrone.Core/Jobs/ConvertEpisodeJob.cs @@ -30,9 +30,9 @@ namespace NzbDrone.Core.Jobs get { return "Convert Episode"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 0; } + get { return TimeSpan.FromTicks(0); } } public void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/DeleteSeriesJob.cs b/NzbDrone.Core/Jobs/DeleteSeriesJob.cs index eaa2915dc..a30aa83ea 100644 --- a/NzbDrone.Core/Jobs/DeleteSeriesJob.cs +++ b/NzbDrone.Core/Jobs/DeleteSeriesJob.cs @@ -24,9 +24,9 @@ namespace NzbDrone.Core.Jobs get { return "Delete Series"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 0; } + get { return TimeSpan.FromTicks(0); } } public void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/DiskScanJob.cs b/NzbDrone.Core/Jobs/DiskScanJob.cs index b82accc84..b9f5719a4 100644 --- a/NzbDrone.Core/Jobs/DiskScanJob.cs +++ b/NzbDrone.Core/Jobs/DiskScanJob.cs @@ -32,9 +32,9 @@ namespace NzbDrone.Core.Jobs get { return "Media File Scan"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 360; } + get { return TimeSpan.FromHours(6); } } public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/EpisodeSearchJob.cs b/NzbDrone.Core/Jobs/EpisodeSearchJob.cs index 3e549fb63..cc18a1fd9 100644 --- a/NzbDrone.Core/Jobs/EpisodeSearchJob.cs +++ b/NzbDrone.Core/Jobs/EpisodeSearchJob.cs @@ -26,9 +26,9 @@ namespace NzbDrone.Core.Jobs get { return "Episode Search"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 0; } + get { return TimeSpan.FromTicks(0); } } public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/IJob.cs b/NzbDrone.Core/Jobs/IJob.cs index 73a9d7023..30cce3775 100644 --- a/NzbDrone.Core/Jobs/IJob.cs +++ b/NzbDrone.Core/Jobs/IJob.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using NzbDrone.Core.Model.Notification; namespace NzbDrone.Core.Jobs @@ -17,7 +18,7 @@ namespace NzbDrone.Core.Jobs /// /// Setting this value to 0 means the job will not be /// executed by the schedule and is only triggered manually. - int DefaultInterval { get; } + TimeSpan DefaultInterval { get; } /// diff --git a/NzbDrone.Core/Jobs/ImportNewSeriesJob.cs b/NzbDrone.Core/Jobs/ImportNewSeriesJob.cs index 0a03430df..6b3f72f2e 100644 --- a/NzbDrone.Core/Jobs/ImportNewSeriesJob.cs +++ b/NzbDrone.Core/Jobs/ImportNewSeriesJob.cs @@ -44,12 +44,12 @@ namespace NzbDrone.Core.Jobs get { return "New Series Update"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 1; } + get { return TimeSpan.FromMinutes(1); } } - public void Start(ProgressNotification notification, int targetId, int secondaryTargetId ) + public void Start(ProgressNotification notification, int targetId, int secondaryTargetId) { _attemptedSeries = new List(); ScanSeries(notification); diff --git a/NzbDrone.Core/Jobs/JobProvider.cs b/NzbDrone.Core/Jobs/JobProvider.cs index dfa2ae8f9..21923db28 100644 --- a/NzbDrone.Core/Jobs/JobProvider.cs +++ b/NzbDrone.Core/Jobs/JobProvider.cs @@ -94,9 +94,9 @@ namespace NzbDrone.Core.Jobs jobDefinition.LastExecution = DateTime.Now; } - jobDefinition.Enable = job.DefaultInterval > 0; + jobDefinition.Enable = job.DefaultInterval.TotalSeconds > 0; jobDefinition.Name = job.Name; - jobDefinition.Interval = job.DefaultInterval; + jobDefinition.Interval = Convert.ToInt32(job.DefaultInterval.TotalMinutes); SaveDefinition(jobDefinition); } diff --git a/NzbDrone.Core/Jobs/PostDownloadScanJob.cs b/NzbDrone.Core/Jobs/PostDownloadScanJob.cs index a4e965624..c021fc9eb 100644 --- a/NzbDrone.Core/Jobs/PostDownloadScanJob.cs +++ b/NzbDrone.Core/Jobs/PostDownloadScanJob.cs @@ -34,9 +34,9 @@ namespace NzbDrone.Core.Jobs get { return "Drop folder monitor"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 1; } + get { return TimeSpan.FromMinutes(1); } } public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs b/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs index 518a2f928..59830a64c 100644 --- a/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs +++ b/NzbDrone.Core/Jobs/RecentBacklogSearchJob.cs @@ -28,9 +28,9 @@ namespace NzbDrone.Core.Jobs get { return "Recent Backlog Search"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 1440; } + get { return TimeSpan.FromDays(1); } } public void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/RenameEpisodeJob.cs b/NzbDrone.Core/Jobs/RenameEpisodeJob.cs index cab50ac41..8fbf1b72f 100644 --- a/NzbDrone.Core/Jobs/RenameEpisodeJob.cs +++ b/NzbDrone.Core/Jobs/RenameEpisodeJob.cs @@ -32,9 +32,9 @@ namespace NzbDrone.Core.Jobs get { return "Rename Episode"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 0; } + get { return TimeSpan.FromTicks(0); } } public void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/RenameSeasonJob.cs b/NzbDrone.Core/Jobs/RenameSeasonJob.cs index 74dd08962..002b6366d 100644 --- a/NzbDrone.Core/Jobs/RenameSeasonJob.cs +++ b/NzbDrone.Core/Jobs/RenameSeasonJob.cs @@ -31,9 +31,9 @@ namespace NzbDrone.Core.Jobs get { return "Rename Season"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 0; } + get { return TimeSpan.FromTicks(0); } } public void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/RenameSeriesJob.cs b/NzbDrone.Core/Jobs/RenameSeriesJob.cs index 19aadfcc1..42bef481f 100644 --- a/NzbDrone.Core/Jobs/RenameSeriesJob.cs +++ b/NzbDrone.Core/Jobs/RenameSeriesJob.cs @@ -31,9 +31,9 @@ namespace NzbDrone.Core.Jobs get { return "Rename Series"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 0; } + get { return TimeSpan.FromTicks(0); } } public void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/RssSyncJob.cs b/NzbDrone.Core/Jobs/RssSyncJob.cs index 80f319061..600e825cb 100644 --- a/NzbDrone.Core/Jobs/RssSyncJob.cs +++ b/NzbDrone.Core/Jobs/RssSyncJob.cs @@ -34,9 +34,9 @@ namespace NzbDrone.Core.Jobs get { return "RSS Sync"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 25; } + get { return TimeSpan.FromMinutes(25); } } public void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/SeasonSearchJob.cs b/NzbDrone.Core/Jobs/SeasonSearchJob.cs index 2074996e3..c9c3d1eeb 100644 --- a/NzbDrone.Core/Jobs/SeasonSearchJob.cs +++ b/NzbDrone.Core/Jobs/SeasonSearchJob.cs @@ -32,9 +32,9 @@ namespace NzbDrone.Core.Jobs get { return "Season Search"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 0; } + get { return TimeSpan.FromTicks(0); } } public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/SeriesSearchJob.cs b/NzbDrone.Core/Jobs/SeriesSearchJob.cs index 4bb50df9e..5e225f1dd 100644 --- a/NzbDrone.Core/Jobs/SeriesSearchJob.cs +++ b/NzbDrone.Core/Jobs/SeriesSearchJob.cs @@ -24,9 +24,9 @@ namespace NzbDrone.Core.Jobs get { return "Series Search"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 0; } + get { return TimeSpan.FromTicks(0); } } public void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/TrimLogsJob.cs b/NzbDrone.Core/Jobs/TrimLogsJob.cs index f6207c2e7..cee44292f 100644 --- a/NzbDrone.Core/Jobs/TrimLogsJob.cs +++ b/NzbDrone.Core/Jobs/TrimLogsJob.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using NzbDrone.Core.Instrumentation; using NzbDrone.Core.Model.Notification; @@ -18,9 +19,9 @@ namespace NzbDrone.Core.Jobs get { return "Trim Logs Job"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 1440; } + get { return TimeSpan.FromDays(1); } } public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/UpdateInfoJob.cs b/NzbDrone.Core/Jobs/UpdateInfoJob.cs index 4217e11cd..db6033b11 100644 --- a/NzbDrone.Core/Jobs/UpdateInfoJob.cs +++ b/NzbDrone.Core/Jobs/UpdateInfoJob.cs @@ -36,9 +36,9 @@ namespace NzbDrone.Core.Jobs get { return "Update Episode Info"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 720; } //12-hours + get { return TimeSpan.FromHours(12); } } public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Core/Jobs/UpdateSceneMappingsJob.cs b/NzbDrone.Core/Jobs/UpdateSceneMappingsJob.cs index 7ccf50164..67267ed01 100644 --- a/NzbDrone.Core/Jobs/UpdateSceneMappingsJob.cs +++ b/NzbDrone.Core/Jobs/UpdateSceneMappingsJob.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Providers; @@ -23,9 +24,9 @@ namespace NzbDrone.Core.Jobs get { return "Update Scene Mappings"; } } - public int DefaultInterval + public TimeSpan DefaultInterval { - get { return 720; } //Every 12 hours + get { return TimeSpan.FromHours(12); } } public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId) diff --git a/NzbDrone.Web/Views/System/Jobs.cshtml b/NzbDrone.Web/Views/System/Jobs.cshtml index ac0e5ff3b..bd8d2a766 100644 --- a/NzbDrone.Web/Views/System/Jobs.cshtml +++ b/NzbDrone.Web/Views/System/Jobs.cshtml @@ -19,9 +19,10 @@ } } )) + .Sortable(c=>c.OrderBy(col=>col.Add(g=>g.Interval))) .Render();} - Items currently in queue +

Items currently in queue

@{Html.Telerik().Grid((IEnumerable)ViewData["Queue"]).Name("QueueGrid") .Columns(c => c.Bound(g => g.Name).Title("Type").Width(100))