Fixed: Filter history by multiple event types

This commit is contained in:
Bogdan 2024-01-12 03:34:22 +02:00
parent 29f1e63955
commit 354533871e
1 changed files with 4 additions and 4 deletions

View File

@ -68,15 +68,15 @@ namespace Lidarr.Api.V1.History
[HttpGet]
[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 pagingSpec = pagingResource.MapToPagingSpec<HistoryResource, EntityHistory>("date", SortDirection.Descending);
if (eventType.HasValue)
if (eventTypes != null && eventTypes.Any())
{
var filterValue = (EntityHistoryEventType)eventType.Value;
pagingSpec.FilterExpressions.Add(v => v.EventType == filterValue);
var filterValues = eventTypes.Cast<EntityHistoryEventType>().ToArray();
pagingSpec.FilterExpressions.Add(v => filterValues.Contains(v.EventType));
}
if (albumId.HasValue)