Fixed: Xem mapped series should be more reliable

pull/2/head
Mark McDowall 11 years ago
parent 5ada7efefc
commit 401a5c9f26

@ -1,8 +0,0 @@
using NzbDrone.Core.Messaging.Commands;
namespace NzbDrone.Core.DataAugmentation.Xem
{
public class RefreshXemCacheCommand : Command
{
}
}

@ -1,15 +1,15 @@
using System;
using System.Linq;
using System.Web.UI.WebControls;
using NLog;
using NzbDrone.Common.Cache;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv;
using NzbDrone.Core.Tv.Events;
namespace NzbDrone.Core.DataAugmentation.Xem
{
public class XemService : IHandle<SeriesUpdatedEvent>, IExecute<RefreshXemCacheCommand>
public class XemService : IHandle<SeriesUpdatedEvent>, IHandle<SeriesRefreshStartingEvent>
{
private readonly IEpisodeService _episodeService;
private readonly IXemProxy _xemProxy;
@ -84,10 +84,13 @@ namespace NzbDrone.Core.DataAugmentation.Xem
private void RefreshCache()
{
_cache.Clear();
var ids = _xemProxy.GetXemSeriesIds();
if (ids.Any())
{
_cache.Clear();
}
foreach (var id in ids)
{
_cache.Set(id.ToString(), true, TimeSpan.FromHours(1));
@ -110,7 +113,7 @@ namespace NzbDrone.Core.DataAugmentation.Xem
PerformUpdate(message.Series);
}
public void Execute(RefreshXemCacheCommand message)
public void Handle(SeriesRefreshStartingEvent message)
{
RefreshCache();
}

@ -53,10 +53,8 @@ namespace NzbDrone.Core.Jobs
new ScheduledTask{ Interval = 1*60, TypeName = typeof(ApplicationUpdateCommand).FullName},
new ScheduledTask{ Interval = 1*60, TypeName = typeof(TrimLogCommand).FullName},
new ScheduledTask{ Interval = 3*60, TypeName = typeof(UpdateSceneMappingCommand).FullName},
new ScheduledTask{ Interval = 12*60, TypeName = typeof(RefreshXemCacheCommand).FullName},
new ScheduledTask{ Interval = 12*60, TypeName = typeof(RefreshSeriesCommand).FullName},
new ScheduledTask{ Interval = 24*60, TypeName = typeof(HousekeepingCommand).FullName},
};
var currentTasks = _scheduledTaskRepository.All();

@ -139,7 +139,6 @@
<Compile Include="DataAugmentation\Xem\Model\XemResult.cs" />
<Compile Include="DataAugmentation\Xem\Model\XemSceneTvdbMapping.cs" />
<Compile Include="DataAugmentation\Xem\Model\XemValues.cs" />
<Compile Include="DataAugmentation\Xem\RefreshXemCacheCommand.cs" />
<Compile Include="DataAugmentation\Xem\XemProxy.cs" />
<Compile Include="DataAugmentation\Xem\XemService.cs" />
<Compile Include="Datastore\ConnectionStringFactory.cs" />
@ -477,6 +476,7 @@
<Compile Include="ThingiProvider\ProviderRepository.cs" />
<Compile Include="ThingiProvider\ProviderFactory.cs" />
<Compile Include="Tv\EpisodeService.cs" />
<Compile Include="Tv\Events\SeriesRefreshStartingEvent.cs" />
<Compile Include="Tv\Events\EpisodeInfoDeletedEvent.cs" />
<Compile Include="Tv\Events\EpisodeInfoUpdatedEvent.cs" />
<Compile Include="Tv\Events\EpisodeInfoAddedEvent.cs" />

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

@ -99,6 +99,8 @@ namespace NzbDrone.Core.Tv
public void Execute(RefreshSeriesCommand message)
{
_eventAggregator.PublishEvent(new SeriesRefreshStartingEvent());
if (message.SeriesId.HasValue)
{
var series = _seriesService.GetSeries(message.SeriesId.Value);

Loading…
Cancel
Save