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

pull/6/head
Mark McDowall 11 years ago
parent 83207a0baf
commit cb291d30b3

@ -4,18 +4,12 @@ using System.Linq;
using NzbDrone.Api.Episodes; using NzbDrone.Api.Episodes;
using NzbDrone.Api.Extensions; using NzbDrone.Api.Extensions;
using NzbDrone.Api.Mapping; 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.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Calendar namespace NzbDrone.Api.Calendar
{ {
public class CalendarModule : NzbDroneRestModuleWithSignalR<EpisodeResource, Episode>, public class CalendarModule : EpisodeModuleWithSignalR<EpisodeResource, Episode>
IHandle<EpisodeGrabbedEvent>,
IHandle<EpisodeDownloadedEvent>
{ {
private readonly IEpisodeService _episodeService; private readonly IEpisodeService _episodeService;
private readonly SeriesRepository _seriesRepository; private readonly SeriesRepository _seriesRepository;
@ -53,24 +47,5 @@ namespace NzbDrone.Api.Calendar
return resources.OrderBy(e => e.AirDateUtc).ToList(); 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);
}
}
} }
} }

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

@ -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);
}
}
}
}

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

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

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

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

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

Loading…
Cancel
Save