Episode activity goes through History now
Do not report exceptions on linux (culture is null and fails)
This commit is contained in:
parent
7d2c6339bc
commit
27511769ae
|
@ -1,39 +0,0 @@
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using NzbDrone.Api.History;
|
|
||||||
using NzbDrone.Api.Mapping;
|
|
||||||
using NzbDrone.Api.REST;
|
|
||||||
using NzbDrone.Core.Datastore.Events;
|
|
||||||
using NzbDrone.Core.Download;
|
|
||||||
using NzbDrone.Core.History;
|
|
||||||
using NzbDrone.Core.MediaFiles.Events;
|
|
||||||
using NzbDrone.Core.Tv;
|
|
||||||
|
|
||||||
namespace NzbDrone.Api.Episodes
|
|
||||||
{
|
|
||||||
public class EpisodeActivityModule : NzbDroneRestModule<HistoryResource>
|
|
||||||
|
|
||||||
{
|
|
||||||
private readonly IHistoryService _historyService;
|
|
||||||
|
|
||||||
public EpisodeActivityModule(IHistoryService historyService)
|
|
||||||
: base("episodes/activity")
|
|
||||||
{
|
|
||||||
_historyService = historyService;
|
|
||||||
|
|
||||||
GetResourceAll = GetActivity;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<HistoryResource> GetActivity()
|
|
||||||
{
|
|
||||||
var episodeId = (int?)Request.Query.EpisodeId;
|
|
||||||
|
|
||||||
if (episodeId == null)
|
|
||||||
{
|
|
||||||
throw new BadRequestException("episodeId is missing");
|
|
||||||
}
|
|
||||||
|
|
||||||
return ToListResource(() => _historyService.ByEpisode(episodeId.Value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,7 @@
|
||||||
using NzbDrone.Core.Datastore;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NzbDrone.Api.Mapping;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.History;
|
using NzbDrone.Core.History;
|
||||||
|
|
||||||
namespace NzbDrone.Api.History
|
namespace NzbDrone.Api.History
|
||||||
|
@ -15,6 +18,8 @@ namespace NzbDrone.Api.History
|
||||||
|
|
||||||
private PagingResource<HistoryResource> GetHistory(PagingResource<HistoryResource> pagingResource)
|
private PagingResource<HistoryResource> GetHistory(PagingResource<HistoryResource> pagingResource)
|
||||||
{
|
{
|
||||||
|
var episodeId = Request.Query.EpisodeId;
|
||||||
|
|
||||||
var pagingSpec = new PagingSpec<Core.History.History>
|
var pagingSpec = new PagingSpec<Core.History.History>
|
||||||
{
|
{
|
||||||
Page = pagingResource.Page,
|
Page = pagingResource.Page,
|
||||||
|
@ -23,6 +28,12 @@ namespace NzbDrone.Api.History
|
||||||
SortDirection = pagingResource.SortDirection
|
SortDirection = pagingResource.SortDirection
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (episodeId.HasValue)
|
||||||
|
{
|
||||||
|
int i = (int)episodeId;
|
||||||
|
pagingSpec.FilterExpression = h => h.EpisodeId == i;
|
||||||
|
}
|
||||||
|
|
||||||
return ApplyToPage(_historyService.Paged, pagingSpec);
|
return ApplyToPage(_historyService.Paged, pagingSpec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,6 @@
|
||||||
<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\EpisodeActivityModule.cs" />
|
|
||||||
<Compile Include="Episodes\EpisodeModule.cs" />
|
<Compile Include="Episodes\EpisodeModule.cs" />
|
||||||
<Compile Include="Episodes\EpisodeResource.cs" />
|
<Compile Include="Episodes\EpisodeResource.cs" />
|
||||||
<Compile Include="Extensions\Pipelines\CacheHeaderPipeline.cs" />
|
<Compile Include="Extensions\Pipelines\CacheHeaderPipeline.cs" />
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace NzbDrone.Common.Instrumentation
|
||||||
protected override void Write(LogEventInfo logEvent)
|
protected override void Write(LogEventInfo logEvent)
|
||||||
{
|
{
|
||||||
if (logEvent == null || logEvent.Exception == null) return;
|
if (logEvent == null || logEvent.Exception == null) return;
|
||||||
|
if (OsInfo.IsLinux) return;
|
||||||
|
|
||||||
InternalLogger.Trace("Sending Exception to api.exceptron.com. Process Name: {0}", Process.GetCurrentProcess().ProcessName);
|
InternalLogger.Trace("Sending Exception to api.exceptron.com. Process Name: {0}", Process.GetCurrentProcess().ProcessName);
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,6 @@ namespace NzbDrone.Core.Datastore
|
||||||
.Execute();
|
.Execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public virtual PagingSpec<TModel> GetPaged(PagingSpec<TModel> pagingSpec)
|
public virtual PagingSpec<TModel> GetPaged(PagingSpec<TModel> pagingSpec)
|
||||||
{
|
{
|
||||||
var pagingQuery = Query.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
var pagingQuery = Query.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Datastore
|
namespace NzbDrone.Core.Datastore
|
||||||
{
|
{
|
||||||
|
@ -10,6 +12,7 @@ namespace NzbDrone.Core.Datastore
|
||||||
public string SortKey { get; set; }
|
public string SortKey { get; set; }
|
||||||
public SortDirection SortDirection { get; set; }
|
public SortDirection SortDirection { get; set; }
|
||||||
public List<TModel> Records { get; set; }
|
public List<TModel> Records { get; set; }
|
||||||
|
public Expression<Func<TModel, bool>> FilterExpression { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SortDirection
|
public enum SortDirection
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using Marr.Data.QGen;
|
using Marr.Data.QGen;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
|
@ -11,8 +12,7 @@ namespace NzbDrone.Core.History
|
||||||
public interface IHistoryRepository : IBasicRepository<History>
|
public interface IHistoryRepository : IBasicRepository<History>
|
||||||
{
|
{
|
||||||
void Trim();
|
void Trim();
|
||||||
List<QualityModel> GetEpisodeHistory(int episodeId);
|
List<QualityModel> GetBestQualityInHistory(int episodeId);
|
||||||
List<History> ByEpisode(int episodeId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HistoryRepository : BasicRepository<History>, IHistoryRepository
|
public class HistoryRepository : BasicRepository<History>, IHistoryRepository
|
||||||
|
@ -31,32 +31,29 @@ namespace NzbDrone.Core.History
|
||||||
Delete(c=> c.Date < cutoff);
|
Delete(c=> c.Date < cutoff);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<QualityModel> GetEpisodeHistory(int episodeId)
|
public List<QualityModel> GetBestQualityInHistory(int episodeId)
|
||||||
{
|
{
|
||||||
var history = Query.Where(c => c.EpisodeId == episodeId);
|
var history = Query.Where(c => c.EpisodeId == episodeId);
|
||||||
|
|
||||||
return history.Select(h => h.Quality).ToList();
|
return history.Select(h => h.Quality).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<History> ByEpisode(int episodeId)
|
|
||||||
{
|
|
||||||
return Query.Where(h => h.EpisodeId == episodeId).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override PagingSpec<History> GetPaged(PagingSpec<History> pagingSpec)
|
public override PagingSpec<History> GetPaged(PagingSpec<History> pagingSpec)
|
||||||
{
|
{
|
||||||
var pagingQuery = Query.Join<History, Series>(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id)
|
pagingSpec.Records = GetPagedQuery(pagingSpec).ToList();
|
||||||
.Join<History, Episode>(JoinType.Inner, h => h.Episode, (h, e) => h.EpisodeId == e.Id)
|
pagingSpec.TotalRecords = GetPagedQuery(pagingSpec).GetRowCount();
|
||||||
.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
|
||||||
.Skip(pagingSpec.PagingOffset())
|
|
||||||
.Take(pagingSpec.PageSize);
|
|
||||||
|
|
||||||
pagingSpec.Records = pagingQuery.ToList();
|
|
||||||
|
|
||||||
//TODO: Use the same query for count and records
|
|
||||||
pagingSpec.TotalRecords = Count();
|
|
||||||
|
|
||||||
return pagingSpec;
|
return pagingSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SortBuilder<History> GetPagedQuery(PagingSpec<History> pagingSpec)
|
||||||
|
{
|
||||||
|
return Query.Join<History, Series>(JoinType.Inner, h => h.Series, (h, s) => h.SeriesId == s.Id)
|
||||||
|
.Join<History, Episode>(JoinType.Inner, h => h.Episode, (h, e) => h.EpisodeId == e.Id)
|
||||||
|
.Where(pagingSpec.FilterExpression)
|
||||||
|
.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
||||||
|
.Skip(pagingSpec.PagingOffset())
|
||||||
|
.Take(pagingSpec.PageSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
|
@ -17,7 +18,6 @@ namespace NzbDrone.Core.History
|
||||||
void Trim();
|
void Trim();
|
||||||
QualityModel GetBestQualityInHistory(int episodeId);
|
QualityModel GetBestQualityInHistory(int episodeId);
|
||||||
PagingSpec<History> Paged(PagingSpec<History> pagingSpec);
|
PagingSpec<History> Paged(PagingSpec<History> pagingSpec);
|
||||||
List<History> ByEpisode(int episodeId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HistoryService : IHistoryService, IHandle<EpisodeGrabbedEvent>, IHandle<EpisodeImportedEvent>
|
public class HistoryService : IHistoryService, IHandle<EpisodeGrabbedEvent>, IHandle<EpisodeImportedEvent>
|
||||||
|
@ -41,11 +41,6 @@ namespace NzbDrone.Core.History
|
||||||
return _historyRepository.GetPaged(pagingSpec);
|
return _historyRepository.GetPaged(pagingSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<History> ByEpisode(int episodeId)
|
|
||||||
{
|
|
||||||
return _historyRepository.ByEpisode(episodeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Purge()
|
public void Purge()
|
||||||
{
|
{
|
||||||
_historyRepository.Purge();
|
_historyRepository.Purge();
|
||||||
|
@ -58,7 +53,7 @@ namespace NzbDrone.Core.History
|
||||||
|
|
||||||
public virtual QualityModel GetBestQualityInHistory(int episodeId)
|
public virtual QualityModel GetBestQualityInHistory(int episodeId)
|
||||||
{
|
{
|
||||||
return _historyRepository.GetEpisodeHistory(episodeId).OrderByDescending(q => q).FirstOrDefault();
|
return _historyRepository.GetBestQualityInHistory(episodeId).OrderByDescending(q => q).FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(EpisodeGrabbedEvent message)
|
public void Handle(EpisodeGrabbedEvent message)
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
'use strict';
|
|
||||||
define(
|
|
||||||
[
|
|
||||||
'backbone',
|
|
||||||
'Episode/Activity/EpisodeActivityModel'
|
|
||||||
], function (Backbone, EpisodeActivityModel) {
|
|
||||||
return Backbone.Collection.extend({
|
|
||||||
url : window.NzbDrone.ApiRoot + '/episodes/activity',
|
|
||||||
model: EpisodeActivityModel,
|
|
||||||
|
|
||||||
originalFetch: Backbone.Collection.prototype.fetch,
|
|
||||||
|
|
||||||
initialize: function (options) {
|
|
||||||
if (!options.episodeId) {
|
|
||||||
throw 'episodeId is required';
|
|
||||||
}
|
|
||||||
|
|
||||||
this.episodeId = options.episodeId;
|
|
||||||
},
|
|
||||||
|
|
||||||
fetch: function (options) {
|
|
||||||
options = options || {};
|
|
||||||
options.data = { episodeId: this.episodeId };
|
|
||||||
|
|
||||||
return this.originalFetch.call(this, options);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -4,12 +4,12 @@ define(
|
||||||
'app',
|
'app',
|
||||||
'marionette',
|
'marionette',
|
||||||
'backgrid',
|
'backgrid',
|
||||||
'Episode/Activity/EpisodeActivityCollection',
|
'History/HistoryCollection',
|
||||||
'Cells/EventTypeCell',
|
'Cells/EventTypeCell',
|
||||||
'Cells/QualityCell',
|
'Cells/QualityCell',
|
||||||
'Cells/RelativeDateCell',
|
'Cells/RelativeDateCell',
|
||||||
'Shared/LoadingView'
|
'Shared/LoadingView'
|
||||||
], function (App, Marionette, Backgrid, EpisodeActivityCollection, EventTypeCell, QualityCell, RelativeDateCell, LoadingView) {
|
], function (App, Marionette, Backgrid, HistoryCollection, EventTypeCell, QualityCell, RelativeDateCell, LoadingView) {
|
||||||
|
|
||||||
return Marionette.Layout.extend({
|
return Marionette.Layout.extend({
|
||||||
template: 'Episode/Activity/EpisodeActivityLayoutTemplate',
|
template: 'Episode/Activity/EpisodeActivityLayoutTemplate',
|
||||||
|
@ -47,7 +47,7 @@ define(
|
||||||
this.model = options.model;
|
this.model = options.model;
|
||||||
this.series = options.series;
|
this.series = options.series;
|
||||||
|
|
||||||
this.collection = new EpisodeActivityCollection({ episodeId: this.model.id });
|
this.collection = new HistoryCollection({ episodeId: this.model.id });
|
||||||
this.collection.fetch();
|
this.collection.fetch();
|
||||||
this.listenTo(this.collection, 'sync', this._showTable);
|
this.listenTo(this.collection, 'sync', this._showTable);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
'use strict';
|
|
||||||
define(
|
|
||||||
[
|
|
||||||
'backbone'
|
|
||||||
], function (Backbone) {
|
|
||||||
return Backbone.Model.extend({
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -26,6 +26,16 @@ define(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initialize: function (options) {
|
||||||
|
delete this.queryParams.episodeId;
|
||||||
|
|
||||||
|
if (options) {
|
||||||
|
if (options.episodeId) {
|
||||||
|
this.queryParams.episodeId = options.episodeId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
parseState: function (resp) {
|
parseState: function (resp) {
|
||||||
return { totalRecords: resp.totalRecords };
|
return { totalRecords: resp.totalRecords };
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue