parent
12065948ca
commit
2a0df7e83e
|
@ -1,7 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using NzbDrone.Api.Episodes;
|
using NzbDrone.Api.Episodes;
|
||||||
using NzbDrone.Api.Extensions;
|
using NzbDrone.Api.Extensions;
|
||||||
|
using NzbDrone.Api.REST;
|
||||||
using NzbDrone.Api.Series;
|
using NzbDrone.Api.Series;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.DecisionEngine;
|
using NzbDrone.Core.DecisionEngine;
|
||||||
|
@ -25,6 +28,7 @@ namespace NzbDrone.Api.History
|
||||||
_failedDownloadService = failedDownloadService;
|
_failedDownloadService = failedDownloadService;
|
||||||
GetResourcePaged = GetHistory;
|
GetResourcePaged = GetHistory;
|
||||||
|
|
||||||
|
Get["/since"] = x => GetHistorySince();
|
||||||
Post["/failed"] = x => MarkAsFailed();
|
Post["/failed"] = x => MarkAsFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +68,27 @@ namespace NzbDrone.Api.History
|
||||||
return ApplyToPage(_historyService.Paged, pagingSpec, MapToResource);
|
return ApplyToPage(_historyService.Paged, pagingSpec, MapToResource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<HistoryResource> GetHistorySince()
|
||||||
|
{
|
||||||
|
var queryDate = Request.Query.Date;
|
||||||
|
var queryEventType = Request.Query.EventType;
|
||||||
|
|
||||||
|
if (!queryDate.HasValue)
|
||||||
|
{
|
||||||
|
throw new BadRequestException("date is missing");
|
||||||
|
}
|
||||||
|
|
||||||
|
DateTime date = DateTime.Parse(queryDate.Value);
|
||||||
|
HistoryEventType? eventType = null;
|
||||||
|
|
||||||
|
if (queryEventType.HasValue)
|
||||||
|
{
|
||||||
|
eventType = (HistoryEventType)Convert.ToInt32(queryEventType.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return _historyService.Since(date, eventType).Select(MapToResource).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
private Response MarkAsFailed()
|
private Response MarkAsFailed()
|
||||||
{
|
{
|
||||||
var id = (int)Request.Form.Id;
|
var id = (int)Request.Form.Id;
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
using FluentMigrator;
|
||||||
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
{
|
||||||
|
[Migration(118)]
|
||||||
|
public class add_history_eventType_index : NzbDroneMigrationBase
|
||||||
|
{
|
||||||
|
protected override void MainDbUpgrade()
|
||||||
|
{
|
||||||
|
Create.Index().OnTable("History").OnColumn("EventType");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Marr.Data.QGen;
|
using Marr.Data.QGen;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
|
@ -16,6 +17,7 @@ namespace NzbDrone.Core.History
|
||||||
List<History> FindByDownloadId(string downloadId);
|
List<History> FindByDownloadId(string downloadId);
|
||||||
List<History> FindDownloadHistory(int idSeriesId, QualityModel quality);
|
List<History> FindDownloadHistory(int idSeriesId, QualityModel quality);
|
||||||
void DeleteForSeries(int seriesId);
|
void DeleteForSeries(int seriesId);
|
||||||
|
List<History> Since(DateTime date, HistoryEventType? eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HistoryRepository : BasicRepository<History>, IHistoryRepository
|
public class HistoryRepository : BasicRepository<History>, IHistoryRepository
|
||||||
|
@ -76,5 +78,19 @@ namespace NzbDrone.Core.History
|
||||||
|
|
||||||
return base.GetPagedQuery(baseQuery, pagingSpec);
|
return base.GetPagedQuery(baseQuery, pagingSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<History> Since(DateTime date, HistoryEventType? eventType)
|
||||||
|
{
|
||||||
|
var query = Query.Where(h => h.Date >= date);
|
||||||
|
|
||||||
|
if (eventType.HasValue)
|
||||||
|
{
|
||||||
|
query.AndWhere(h => h.EventType == eventType);
|
||||||
|
}
|
||||||
|
|
||||||
|
query.OrderBy(h => h.Date);
|
||||||
|
|
||||||
|
return query;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -25,6 +25,7 @@ namespace NzbDrone.Core.History
|
||||||
History Get(int historyId);
|
History Get(int historyId);
|
||||||
List<History> Find(string downloadId, HistoryEventType eventType);
|
List<History> Find(string downloadId, HistoryEventType eventType);
|
||||||
List<History> FindByDownloadId(string downloadId);
|
List<History> FindByDownloadId(string downloadId);
|
||||||
|
List<History> Since(DateTime date, HistoryEventType? eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HistoryService : IHistoryService,
|
public class HistoryService : IHistoryService,
|
||||||
|
@ -290,5 +291,10 @@ namespace NzbDrone.Core.History
|
||||||
{
|
{
|
||||||
_historyRepository.DeleteForSeries(message.Series.Id);
|
_historyRepository.DeleteForSeries(message.Series.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<History> Since(DateTime date, HistoryEventType? eventType)
|
||||||
|
{
|
||||||
|
return _historyRepository.Since(date, eventType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,6 +224,7 @@
|
||||||
<Compile Include="Datastore\Migration\042_add_download_clients_table.cs" />
|
<Compile Include="Datastore\Migration\042_add_download_clients_table.cs" />
|
||||||
<Compile Include="Datastore\Migration\043_convert_config_to_download_clients.cs" />
|
<Compile Include="Datastore\Migration\043_convert_config_to_download_clients.cs" />
|
||||||
<Compile Include="Datastore\Migration\044_fix_xbmc_episode_metadata.cs" />
|
<Compile Include="Datastore\Migration\044_fix_xbmc_episode_metadata.cs" />
|
||||||
|
<Compile Include="Datastore\Migration\118_add_history_eventType_index.cs" />
|
||||||
<Compile Include="Datastore\Migration\045_add_indexes.cs" />
|
<Compile Include="Datastore\Migration\045_add_indexes.cs" />
|
||||||
<Compile Include="Datastore\Migration\046_fix_nzb_su_url.cs" />
|
<Compile Include="Datastore\Migration\046_fix_nzb_su_url.cs" />
|
||||||
<Compile Include="Datastore\Migration\047_add_published_date_blacklist_column.cs" />
|
<Compile Include="Datastore\Migration\047_add_published_date_blacklist_column.cs" />
|
||||||
|
|
Loading…
Reference in New Issue