Jobs now use Timespan rather than integer to represent minutes.

pull/7/merge
kay.one 13 years ago
parent 624b6e5acb
commit e358ad6d87

@ -250,7 +250,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
//assert //assert
var timers = jobProvider.All(); var timers = jobProvider.All();
timers.Should().HaveCount(1); 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].Name.Should().Be(fakeJob.Name);
timers[0].TypeName.Should().Be(fakeJob.GetType().ToString()); timers[0].TypeName.Should().Be(fakeJob.GetType().ToString());
timers[0].LastExecution.Should().HaveYear(DateTime.Now.Year); timers[0].LastExecution.Should().HaveYear(DateTime.Now.Year);
@ -354,7 +354,7 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
registeredJobs.Should().HaveCount(1); registeredJobs.Should().HaveCount(1);
registeredJobs.First().TypeName.Should().Be(fakeJob.GetType().ToString()); registeredJobs.First().TypeName.Should().Be(fakeJob.GetType().ToString());
registeredJobs.First().Name.Should().Be(fakeJob.Name); 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().Enable.Should().Be(true);
registeredJobs.First().Success.Should().Be(initialFakeJob.Success); registeredJobs.First().Success.Should().Be(initialFakeJob.Success);

@ -14,9 +14,9 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
get { return GetType().Name; } 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; } public int ExecutionCount { get; private set; }
@ -36,9 +36,9 @@ namespace NzbDrone.Core.Test.ProviderTests.JobProviderTests
public class DisabledJob : FakeJob public class DisabledJob : FakeJob
{ {
public override int DefaultInterval public override TimeSpan DefaultInterval
{ {
get { return 0; } get { return TimeSpan.FromTicks(0); }
} }
} }

@ -1,4 +1,5 @@
using System.Linq; using System;
using System.Linq;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using NLog; using NLog;
@ -39,9 +40,9 @@ namespace NzbDrone.Core.Jobs
get { return "Update Application Job"; } 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) public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -1,4 +1,5 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using NLog; using NLog;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
@ -31,9 +32,9 @@ namespace NzbDrone.Core.Jobs
get { return "Backlog Search"; } 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) public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -40,10 +40,9 @@ namespace NzbDrone.Core.Jobs
get { return "Banner Download"; } get { return "Banner Download"; }
} }
public int DefaultInterval public TimeSpan DefaultInterval
{ {
//30 days get { return TimeSpan.FromDays(30); }
get { return 43200; }
} }
public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId) public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -30,9 +30,9 @@ namespace NzbDrone.Core.Jobs
get { return "Convert Episode"; } 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) public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -24,9 +24,9 @@ namespace NzbDrone.Core.Jobs
get { return "Delete Series"; } 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) public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -32,9 +32,9 @@ namespace NzbDrone.Core.Jobs
get { return "Media File Scan"; } 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) public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -26,9 +26,9 @@ namespace NzbDrone.Core.Jobs
get { return "Episode Search"; } 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) public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -1,4 +1,5 @@
using System.Linq; using System;
using System.Linq;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
namespace NzbDrone.Core.Jobs namespace NzbDrone.Core.Jobs
@ -17,7 +18,7 @@ namespace NzbDrone.Core.Jobs
/// </summary> /// </summary>
/// <remarks>Setting this value to 0 means the job will not be /// <remarks>Setting this value to 0 means the job will not be
/// executed by the schedule and is only triggered manually.</remarks> /// executed by the schedule and is only triggered manually.</remarks>
int DefaultInterval { get; } TimeSpan DefaultInterval { get; }
/// <summary> /// <summary>

@ -44,12 +44,12 @@ namespace NzbDrone.Core.Jobs
get { return "New Series Update"; } 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<int>(); _attemptedSeries = new List<int>();
ScanSeries(notification); ScanSeries(notification);

@ -94,9 +94,9 @@ namespace NzbDrone.Core.Jobs
jobDefinition.LastExecution = DateTime.Now; jobDefinition.LastExecution = DateTime.Now;
} }
jobDefinition.Enable = job.DefaultInterval > 0; jobDefinition.Enable = job.DefaultInterval.TotalSeconds > 0;
jobDefinition.Name = job.Name; jobDefinition.Name = job.Name;
jobDefinition.Interval = job.DefaultInterval; jobDefinition.Interval = Convert.ToInt32(job.DefaultInterval.TotalMinutes);
SaveDefinition(jobDefinition); SaveDefinition(jobDefinition);
} }

@ -34,9 +34,9 @@ namespace NzbDrone.Core.Jobs
get { return "Drop folder monitor"; } 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) public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -28,9 +28,9 @@ namespace NzbDrone.Core.Jobs
get { return "Recent Backlog Search"; } 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) public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -32,9 +32,9 @@ namespace NzbDrone.Core.Jobs
get { return "Rename Episode"; } 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) public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -31,9 +31,9 @@ namespace NzbDrone.Core.Jobs
get { return "Rename Season"; } 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) public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -31,9 +31,9 @@ namespace NzbDrone.Core.Jobs
get { return "Rename Series"; } 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) public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -34,9 +34,9 @@ namespace NzbDrone.Core.Jobs
get { return "RSS Sync"; } 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) public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -32,9 +32,9 @@ namespace NzbDrone.Core.Jobs
get { return "Season Search"; } 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) public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -24,9 +24,9 @@ namespace NzbDrone.Core.Jobs
get { return "Series Search"; } 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) public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -1,4 +1,5 @@
using System.Linq; using System;
using System.Linq;
using NzbDrone.Core.Instrumentation; using NzbDrone.Core.Instrumentation;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
@ -18,9 +19,9 @@ namespace NzbDrone.Core.Jobs
get { return "Trim Logs Job"; } 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) public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -36,9 +36,9 @@ namespace NzbDrone.Core.Jobs
get { return "Update Episode Info"; } 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) public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -1,4 +1,5 @@
using System.Linq; using System;
using System.Linq;
using NzbDrone.Core.Model.Notification; using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
@ -23,9 +24,9 @@ namespace NzbDrone.Core.Jobs
get { return "Update Scene Mappings"; } 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) public virtual void Start(ProgressNotification notification, int targetId, int secondaryTargetId)

@ -19,9 +19,10 @@
} }
} }
</text>)) </text>))
.Sortable(c=>c.OrderBy(col=>col.Add(g=>g.Interval)))
.Render();} .Render();}
Items currently in queue <h1>Items currently in queue</h1>
@{Html.Telerik().Grid((IEnumerable<JobQueueItemModel>)ViewData["Queue"]).Name("QueueGrid") @{Html.Telerik().Grid((IEnumerable<JobQueueItemModel>)ViewData["Queue"]).Name("QueueGrid")
.Columns(c => c.Bound(g => g.Name).Title("Type").Width(100)) .Columns(c => c.Bound(g => g.Name).Title("Type").Width(100))

Loading…
Cancel
Save