1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-25 09:18:34 +00:00

User can now configure RSS Sync Interval

This commit is contained in:
Mark McDowall 2013-08-05 22:22:58 -07:00
parent 3a3d43b702
commit 083f649b5c
6 changed files with 50 additions and 11 deletions

View file

@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Configuration.Events;
using NzbDrone.Core.Download;
using NzbDrone.Core.Download.Clients.Nzbget;
using NzbDrone.Core.Download.Clients.Sabnzbd;
@ -16,12 +18,14 @@ namespace NzbDrone.Core.Configuration
public class ConfigService : IConfigService
{
private readonly IConfigRepository _repository;
private readonly IMessageAggregator _messageAggregator;
private readonly Logger _logger;
private static Dictionary<string, string> _cache;
public ConfigService(IConfigRepository repository, Logger logger)
public ConfigService(IConfigRepository repository, IMessageAggregator messageAggregator, Logger logger)
{
_repository = repository;
_messageAggregator = messageAggregator;
_logger = logger;
_cache = new Dictionary<string, string>();
}
@ -63,6 +67,8 @@ namespace NzbDrone.Core.Configuration
if (!equal)
SetValue(configValue.Key, configValue.Value.ToString());
}
_messageAggregator.PublishEvent(new ConfigSavedEvent());
}
public String SabHost
@ -238,6 +244,13 @@ namespace NzbDrone.Core.Configuration
set { SetValue("ReleaseRestrictions", value); }
}
public Int32 RssSyncInterval
{
get { return GetValueInt("RssSyncInterval", 15); }
set { SetValue("RssSyncInterval", value); }
}
private string GetValue(string key)
{
return GetValue(key, String.Empty);

View file

@ -0,0 +1,8 @@
using NzbDrone.Common.Messaging;
namespace NzbDrone.Core.Configuration.Events
{
public class ConfigSavedEvent : IEvent
{
}
}

View file

@ -36,6 +36,7 @@ namespace NzbDrone.Core.Configuration
PriorityType NzbgetRecentTvPriority { get; set; }
PriorityType NzbgetOlderTvPriority { get; set; }
string ReleaseRestrictions { get; set; }
Int32 RssSyncInterval { get; set; }
void SaveValues(Dictionary<string, object> configValues);
}
}

View file

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using NLog;
using NzbDrone.Common.Messaging;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Configuration.Events;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Instrumentation.Commands;
using NzbDrone.Core.Lifecycle;
@ -18,18 +20,19 @@ namespace NzbDrone.Core.Jobs
IList<ScheduledTask> GetPending();
}
public class TaskManager : IHandle<ApplicationStartedEvent>, IHandleAsync<CommandExecutedEvent>, ITaskManager
public class TaskManager : ITaskManager, IHandle<ApplicationStartedEvent>, IHandleAsync<CommandExecutedEvent>, IHandleAsync<ConfigSavedEvent>
{
private readonly IScheduledTaskRepository _scheduledTaskRepository;
private readonly IConfigService _configService;
private readonly Logger _logger;
public TaskManager(IScheduledTaskRepository scheduledTaskRepository, Logger logger)
public TaskManager(IScheduledTaskRepository scheduledTaskRepository, IConfigService configService, Logger logger)
{
_scheduledTaskRepository = scheduledTaskRepository;
_configService = configService;
_logger = logger;
}
public IList<ScheduledTask> GetPending()
{
return _scheduledTaskRepository.All().Where(c => c.LastExecution.AddMinutes(c.Interval) < DateTime.UtcNow).ToList();
@ -39,7 +42,7 @@ namespace NzbDrone.Core.Jobs
{
var defaultTasks = new[]
{
new ScheduledTask{ Interval = 15, TypeName = typeof(RssSyncCommand).FullName},
new ScheduledTask{ Interval = _configService.RssSyncInterval, TypeName = typeof(RssSyncCommand).FullName},
new ScheduledTask{ Interval = 12*60, TypeName = typeof(UpdateXemMappingsCommand).FullName},
new ScheduledTask{ Interval = 12*60, TypeName = typeof(RefreshSeriesCommand).FullName},
new ScheduledTask{ Interval = 1, TypeName = typeof(DownloadedEpisodesScanCommand).FullName},
@ -80,5 +83,12 @@ namespace NzbDrone.Core.Jobs
_scheduledTaskRepository.SetLastExecutionTime(scheduledTask.Id, DateTime.UtcNow);
}
}
public void HandleAsync(ConfigSavedEvent message)
{
var rss = _scheduledTaskRepository.GetDefinition(typeof (RssSyncCommand));
rss.Interval = _configService.RssSyncInterval;
_scheduledTaskRepository.Update(rss);
}
}
}

View file

@ -117,6 +117,7 @@
<Compile Include="Configuration\ConfigFileProvider.cs" />
<Compile Include="Configuration\ConfigRepository.cs" />
<Compile Include="Configuration\Events\ConfigFileSavedEvent.cs" />
<Compile Include="Configuration\Events\ConfigSavedEvent.cs" />
<Compile Include="Configuration\IConfigService.cs" />
<Compile Include="DataAugmentation\DailySeries\DailySeriesDataProxy.cs" />
<Compile Include="DataAugmentation\DailySeries\DailySeriesService.cs" />

View file

@ -9,22 +9,28 @@
</div>
</div>
<!--<div class="control-group">-->
<!--<label class="control-label">RSS Sync Interval</label>-->
<div class="control-group">
<label class="control-label">RSS Sync Interval</label>
<!--<div class="controls">-->
<!--<input type="number" min="15" max="120" name="rssSyncInterval"/>-->
<!--</div>-->
<!--</div>-->
<div class="controls">
<input type="number" min="10" max="120" name="rssSyncInterval"/>
<span class="help-inline">
<i class="icon-form-warning" title="This will apply to all indexers, please follow the rules set forth by them"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Release Restrictions</label>
<div class="controls">
<textarea rows="3" name="releaseRestrictions" class="release-restrictions"></textarea>
<span class="help-inline">
<i class="icon-question-sign" title="Blacklist NZBs based on these words (case-insensitive)"/>
</span>
<span class="text-area-help">Newline-delimited set of rules</span>
</div>
</div>