New: Artist History Modal in Artist Details Page

This commit is contained in:
Qstick 2017-12-13 22:38:27 -05:00
parent 0981260887
commit 7e4a8c8ff7
17 changed files with 659 additions and 96 deletions

View file

@ -31,6 +31,7 @@ namespace Lidarr.Api.V1.History
GetResourcePaged = GetHistory;
Get["/since"] = x => GetHistorySince();
Get["/artist"] = x => GetArtistHistory();
Post["/failed"] = x => MarkAsFailed();
}
@ -109,6 +110,38 @@ namespace Lidarr.Api.V1.History
return _historyService.Since(date, eventType).Select(h => MapToResource(h, includeArtist, includeAlbum, includeTrack)).ToList();
}
private List<HistoryResource> GetArtistHistory()
{
var queryArtistId = Request.Query.ArtistId;
var queryAlbumId = Request.Query.AlbumId;
var queryEventType = Request.Query.EventType;
if (!queryArtistId.HasValue)
{
throw new BadRequestException("artistId is missing");
}
int artistId = Convert.ToInt32(queryArtistId.Value);
HistoryEventType? eventType = null;
var includeArtist = Request.GetBooleanQueryParameter("includeArtist");
var includeAlbum = Request.GetBooleanQueryParameter("includeAlbum");
var includeTrack = Request.GetBooleanQueryParameter("includeTrack");
if (queryEventType.HasValue)
{
eventType = (HistoryEventType)Convert.ToInt32(queryEventType.Value);
}
if (queryAlbumId.HasValue)
{
int albumId = Convert.ToInt32(queryAlbumId.Value);
return _historyService.GetByAlbum(artistId, albumId, eventType).Select(h => MapToResource(h, includeArtist, includeAlbum, includeTrack)).ToList();
}
return _historyService.GetByArtist(artistId, eventType).Select(h => MapToResource(h, includeArtist, includeAlbum, includeTrack)).ToList();
}
private Response MarkAsFailed()
{
var id = (int)Request.Form.Id;