From dbf34e674080438926d17f026fcac5f81252e1d7 Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Fri, 6 Jan 2017 16:11:41 +0100 Subject: [PATCH] Updated Interval to scan for finished downloads to .25 minutes. --- src/NzbDrone.Api/System/Tasks/TaskResource.cs | 2 +- .../Migration/108_update_schedule_interval.cs | 15 +++++++++++++++ src/NzbDrone.Core/Datastore/TableMapping.cs | 1 + src/NzbDrone.Core/Jobs/ScheduledTask.cs | 2 +- src/NzbDrone.Core/Jobs/TaskManager.cs | 2 +- src/NzbDrone.Core/NzbDrone.Core.csproj | 1 + 6 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 src/NzbDrone.Core/Datastore/Migration/108_update_schedule_interval.cs diff --git a/src/NzbDrone.Api/System/Tasks/TaskResource.cs b/src/NzbDrone.Api/System/Tasks/TaskResource.cs index fda392cae..d4b583aa5 100644 --- a/src/NzbDrone.Api/System/Tasks/TaskResource.cs +++ b/src/NzbDrone.Api/System/Tasks/TaskResource.cs @@ -7,7 +7,7 @@ public class TaskResource : RestResource { public string Name { get; set; } public string TaskName { get; set; } - public int Interval { get; set; } + public double Interval { get; set; } public DateTime LastExecution { get; set; } public DateTime NextExecution { get; set; } } diff --git a/src/NzbDrone.Core/Datastore/Migration/108_update_schedule_interval.cs b/src/NzbDrone.Core/Datastore/Migration/108_update_schedule_interval.cs new file mode 100644 index 000000000..82f204b3e --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/108_update_schedule_interval.cs @@ -0,0 +1,15 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(108)] + public class update_schedule_intervale : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("ScheduledTasks").AlterColumn("Interval").AsDouble(); + Execute.Sql("UPDATE ScheduledTasks SET Interval=0.25 WHERE TypeName='NzbDrone.Core.Download.CheckForFinishedDownloadCommand'"); + } + } +} diff --git a/src/NzbDrone.Core/Datastore/TableMapping.cs b/src/NzbDrone.Core/Datastore/TableMapping.cs index 65a82948b..30c0b038f 100644 --- a/src/NzbDrone.Core/Datastore/TableMapping.cs +++ b/src/NzbDrone.Core/Datastore/TableMapping.cs @@ -140,6 +140,7 @@ private static void RegisterMappers() RegisterEmbeddedConverter(); RegisterProviderSettingConverter(); + MapRepository.Instance.RegisterTypeConverter(typeof(int), new Int32Converter()); MapRepository.Instance.RegisterTypeConverter(typeof(double), new DoubleConverter()); MapRepository.Instance.RegisterTypeConverter(typeof(DateTime), new UtcConverter()); diff --git a/src/NzbDrone.Core/Jobs/ScheduledTask.cs b/src/NzbDrone.Core/Jobs/ScheduledTask.cs index 5d842696d..a91faf3d1 100644 --- a/src/NzbDrone.Core/Jobs/ScheduledTask.cs +++ b/src/NzbDrone.Core/Jobs/ScheduledTask.cs @@ -6,7 +6,7 @@ namespace NzbDrone.Core.Jobs public class ScheduledTask : ModelBase { public string TypeName { get; set; } - public int Interval { get; set; } + public double Interval { get; set; } public DateTime LastExecution { get; set; } } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Jobs/TaskManager.cs b/src/NzbDrone.Core/Jobs/TaskManager.cs index 3ad7b909a..33ba087b4 100644 --- a/src/NzbDrone.Core/Jobs/TaskManager.cs +++ b/src/NzbDrone.Core/Jobs/TaskManager.cs @@ -61,7 +61,7 @@ public void Handle(ApplicationStartedEvent message) { var defaultTasks = new[] { - new ScheduledTask{ Interval = 1, TypeName = typeof(CheckForFinishedDownloadCommand).FullName}, + new ScheduledTask{ Interval = 0.25f, TypeName = typeof(CheckForFinishedDownloadCommand).FullName}, new ScheduledTask{ Interval = 5, TypeName = typeof(MessagingCleanupCommand).FullName}, new ScheduledTask{ Interval = 6*60, TypeName = typeof(ApplicationUpdateCommand).FullName}, new ScheduledTask{ Interval = 3*60, TypeName = typeof(UpdateSceneMappingCommand).FullName}, diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 1de7d14ea..14d74a9e5 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -183,6 +183,7 @@ +