Skip to content

Commit

Permalink
Fixed: Filter history by multiple event types
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisbogdan committed Jan 12, 2024
1 parent 29f1e63 commit 3545338
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Lidarr.Api.V1/History/HistoryController.cs
Expand Up @@ -68,15 +68,15 @@ protected HistoryResource MapToResource(EntityHistory model, bool includeArtist,

[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)
Expand Down

0 comments on commit 3545338

Please sign in to comment.