1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-01-17 10:45:49 +02:00

New: Missing/Cutoff Unmet will update when an episode is grabbed

This commit is contained in:
Mark McDowall 2014-06-25 01:31:37 -07:00
parent 83207a0baf
commit cb291d30b3
8 changed files with 65 additions and 42 deletions

View File

@ -4,18 +4,12 @@
using NzbDrone.Api.Episodes;
using NzbDrone.Api.Extensions;
using NzbDrone.Api.Mapping;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Calendar
{
public class CalendarModule : NzbDroneRestModuleWithSignalR<EpisodeResource, Episode>,
IHandle<EpisodeGrabbedEvent>,
IHandle<EpisodeDownloadedEvent>
public class CalendarModule : EpisodeModuleWithSignalR<EpisodeResource, Episode>
{
private readonly IEpisodeService _episodeService;
private readonly SeriesRepository _seriesRepository;
@ -53,24 +47,5 @@ private List<EpisodeResource> GetCalendar()
return resources.OrderBy(e => e.AirDateUtc).ToList();
}
public void Handle(EpisodeGrabbedEvent message)
{
foreach (var episode in message.Episode.Episodes)
{
var resource = episode.InjectTo<EpisodeResource>();
resource.Grabbed = true;
BroadcastResourceChange(ModelAction.Updated, resource);
}
}
public void Handle(EpisodeDownloadedEvent message)
{
foreach (var episode in message.Episode.Episodes)
{
BroadcastResourceChange(ModelAction.Updated, episode.Id);
}
}
}
}

View File

@ -5,14 +5,11 @@
using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Episodes
{
public class EpisodeModule : NzbDroneRestModuleWithSignalR<EpisodeResource, Episode>,
IHandle<EpisodeGrabbedEvent>,
IHandle<EpisodeDownloadedEvent>
public class EpisodeModule : EpisodeModuleWithSignalR<EpisodeResource, Episode>
{
private readonly IEpisodeService _episodeService;

View File

@ -0,0 +1,46 @@
using NzbDrone.Api.Mapping;
using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Episodes
{
public abstract class EpisodeModuleWithSignalR<TResource, TModel> : NzbDroneRestModuleWithSignalR<TResource, TModel>,
IHandle<EpisodeGrabbedEvent>,
IHandle<EpisodeDownloadedEvent>
where TResource : EpisodeResource, new()
where TModel : Episode
{
protected EpisodeModuleWithSignalR(ICommandExecutor commandExecutor)
: base(commandExecutor)
{
}
protected EpisodeModuleWithSignalR(ICommandExecutor commandExecutor, string resource)
: base(commandExecutor, resource)
{
}
public void Handle(EpisodeGrabbedEvent message)
{
foreach (var episode in message.Episode.Episodes)
{
var resource = episode.InjectTo<TResource>();
resource.Grabbed = true;
BroadcastResourceChange(ModelAction.Updated, resource);
}
}
public void Handle(EpisodeDownloadedEvent message)
{
foreach (var episode in message.Episode.Episodes)
{
BroadcastResourceChange(ModelAction.Updated, episode.Id);
}
}
}
}

View File

@ -117,6 +117,7 @@
<Compile Include="EpisodeFiles\EpisodeFileResource.cs" />
<Compile Include="Directories\DirectoryLookupService.cs" />
<Compile Include="Directories\DirectoryModule.cs" />
<Compile Include="Episodes\EpisodeModuleWithSignalR.cs" />
<Compile Include="Episodes\EpisodeModule.cs" />
<Compile Include="Episodes\EpisodeResource.cs" />
<Compile Include="Episodes\RenameEpisodeModule.cs" />

View File

@ -2,17 +2,18 @@
using NzbDrone.Api.Episodes;
using NzbDrone.Api.Extensions;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Wanted
{
public class CutoffModule : NzbDroneRestModule<EpisodeResource>
public class CutoffModule : EpisodeModuleWithSignalR<EpisodeResource, Episode>
{
private readonly IEpisodeCutoffService _episodeCutoffService;
private readonly SeriesRepository _seriesRepository;
private readonly ISeriesRepository _seriesRepository;
public CutoffModule(IEpisodeCutoffService episodeCutoffService, SeriesRepository seriesRepository)
:base("wanted/cutoff")
public CutoffModule(IEpisodeCutoffService episodeCutoffService, ISeriesRepository seriesRepository, ICommandExecutor commandExecutor)
:base(commandExecutor, "wanted/cutoff")
{
_episodeCutoffService = episodeCutoffService;
_seriesRepository = seriesRepository;

View File

@ -2,17 +2,18 @@
using NzbDrone.Api.Episodes;
using NzbDrone.Api.Extensions;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Wanted
{
public class MissingModule : NzbDroneRestModule<EpisodeResource>
public class MissingModule : EpisodeModuleWithSignalR<EpisodeResource, Episode>
{
private readonly IEpisodeService _episodeService;
private readonly SeriesRepository _seriesRepository;
private readonly ISeriesRepository _seriesRepository;
public MissingModule(IEpisodeService episodeService, SeriesRepository seriesRepository)
:base("wanted/missing")
public MissingModule(IEpisodeService episodeService, ISeriesRepository seriesRepository, ICommandExecutor commandExecutor)
:base(commandExecutor, "wanted/missing")
{
_episodeService = episodeService;
_seriesRepository = seriesRepository;

View File

@ -14,7 +14,8 @@ define([
'Shared/LoadingView',
'Shared/Messenger',
'Commands/CommandController',
'backgrid.selectall'
'backgrid.selectall',
'Mixins/backbone.signalr.mixin'
], function (_,
Marionette,
Backgrid,
@ -81,7 +82,7 @@ define([
],
initialize : function () {
this.collection = new CutoffUnmetCollection();
this.collection = new CutoffUnmetCollection().bindSignalR({ updateOnly: true });
this.listenTo(this.collection, 'sync', this._showTable);
},

View File

@ -14,7 +14,8 @@ define([
'Shared/LoadingView',
'Shared/Messenger',
'Commands/CommandController',
'backgrid.selectall'
'backgrid.selectall',
'Mixins/backbone.signalr.mixin'
], function (_,
Marionette,
Backgrid,
@ -81,7 +82,7 @@ define([
],
initialize : function () {
this.collection = new MissingCollection();
this.collection = new MissingCollection().bindSignalR({ updateOnly: true });
this.listenTo(this.collection, 'sync', this._showTable);
},