mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
Fixed: Linking Next/Last albums for bulk edit artists
Clear statistics cache for ArtistEditedEvent
This commit is contained in:
parent
633feaa023
commit
ed07f82218
3 changed files with 32 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Lidarr.Api.V1.Albums;
|
||||
using Lidarr.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NzbDrone.Common.Extensions;
|
||||
|
@ -13,11 +14,13 @@ namespace Lidarr.Api.V1.Artist
|
|||
public class ArtistEditorController : Controller
|
||||
{
|
||||
private readonly IArtistService _artistService;
|
||||
private readonly IAlbumService _albumService;
|
||||
private readonly IManageCommandQueue _commandQueueManager;
|
||||
|
||||
public ArtistEditorController(IArtistService artistService, IManageCommandQueue commandQueueManager)
|
||||
public ArtistEditorController(IArtistService artistService, IAlbumService albumService, IManageCommandQueue commandQueueManager)
|
||||
{
|
||||
_artistService = artistService;
|
||||
_albumService = albumService;
|
||||
_commandQueueManager = commandQueueManager;
|
||||
}
|
||||
|
||||
|
@ -89,7 +92,11 @@ namespace Lidarr.Api.V1.Artist
|
|||
});
|
||||
}
|
||||
|
||||
return Accepted(_artistService.UpdateArtists(artistToUpdate, !resource.MoveFiles).ToResource());
|
||||
var resources = _artistService.UpdateArtists(artistToUpdate, !resource.MoveFiles).ToResource();
|
||||
|
||||
LinkNextPreviousAlbums(resources.ToArray());
|
||||
|
||||
return Accepted(resources);
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
|
@ -99,5 +106,19 @@ namespace Lidarr.Api.V1.Artist
|
|||
|
||||
return new { };
|
||||
}
|
||||
|
||||
private void LinkNextPreviousAlbums(params ArtistResource[] artists)
|
||||
{
|
||||
var artistMetadataIds = artists.Select(x => x.ArtistMetadataId).Distinct().ToList();
|
||||
|
||||
var nextAlbums = _albumService.GetNextAlbumsByArtistMetadataId(artistMetadataIds);
|
||||
var lastAlbums = _albumService.GetLastAlbumsByArtistMetadataId(artistMetadataIds);
|
||||
|
||||
foreach (var artistResource in artists)
|
||||
{
|
||||
artistResource.NextAlbum = nextAlbums.FirstOrDefault(x => x.ArtistMetadataId == artistResource.ArtistMetadataId).ToResource();
|
||||
artistResource.LastAlbum = lastAlbums.FirstOrDefault(x => x.ArtistMetadataId == artistResource.ArtistMetadataId).ToResource();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,9 +108,7 @@ namespace Lidarr.Api.V1.Artist
|
|||
Tags = model.Tags,
|
||||
Added = model.Added,
|
||||
AddOptions = model.AddOptions,
|
||||
Ratings = model.Metadata.Value.Ratings,
|
||||
|
||||
Statistics = new ArtistStatisticsResource()
|
||||
Ratings = model.Metadata.Value.Ratings
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace NzbDrone.Core.ArtistStats
|
|||
|
||||
public class ArtistStatisticsService : IArtistStatisticsService,
|
||||
IHandle<ArtistAddedEvent>,
|
||||
IHandle<ArtistEditedEvent>,
|
||||
IHandle<ArtistUpdatedEvent>,
|
||||
IHandle<ArtistsDeletedEvent>,
|
||||
IHandle<AlbumAddedEvent>,
|
||||
|
@ -77,6 +78,13 @@ namespace NzbDrone.Core.ArtistStats
|
|||
_cache.Remove(message.Artist.Id.ToString());
|
||||
}
|
||||
|
||||
[EventHandleOrder(EventHandleOrder.First)]
|
||||
public void Handle(ArtistEditedEvent message)
|
||||
{
|
||||
_cache.Remove("AllArtists");
|
||||
_cache.Remove(message.Artist.Id.ToString());
|
||||
}
|
||||
|
||||
[EventHandleOrder(EventHandleOrder.First)]
|
||||
public void Handle(ArtistUpdatedEvent message)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue