Fixed: Filter history by multiple event types

pull/4433/head
Bogdan 4 months ago
parent 29f1e63955
commit 354533871e

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

Loading…
Cancel
Save