Fixed: Filter history by multiple event types

This commit is contained in:
Bogdan
2024-01-07 19:04:22 +02:00
parent 56c8c3d6c6
commit 52a690b41a

View File

@@ -22,15 +22,15 @@ namespace Prowlarr.Api.V1.History
[HttpGet] [HttpGet]
[Produces("application/json")] [Produces("application/json")]
public PagingResource<HistoryResource> GetHistory([FromQuery] PagingRequestResource paging, int? eventType, bool? successful, string downloadId) public PagingResource<HistoryResource> GetHistory([FromQuery] PagingRequestResource paging, [FromQuery(Name = "eventType")] int[] eventTypes, bool? successful, string downloadId)
{ {
var pagingResource = new PagingResource<HistoryResource>(paging); var pagingResource = new PagingResource<HistoryResource>(paging);
var pagingSpec = pagingResource.MapToPagingSpec<HistoryResource, NzbDrone.Core.History.History>("date", SortDirection.Descending); var pagingSpec = pagingResource.MapToPagingSpec<HistoryResource, NzbDrone.Core.History.History>("date", SortDirection.Descending);
if (eventType.HasValue) if (eventTypes != null && eventTypes.Any())
{ {
var filterValue = (HistoryEventType)eventType.Value; var filterValues = eventTypes.Cast<HistoryEventType>().ToArray();
pagingSpec.FilterExpressions.Add(v => v.EventType == filterValue); pagingSpec.FilterExpressions.Add(v => filterValues.Contains(v.EventType));
} }
if (successful.HasValue) if (successful.HasValue)