mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-20 21:43:33 -07:00
parent
6c3b3122f3
commit
d37b226fd4
1 changed files with 19 additions and 3 deletions
|
@ -12,6 +12,7 @@ using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.DecisionEngine.Specifications;
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
||||||
using NzbDrone.Core.Download;
|
using NzbDrone.Core.Download;
|
||||||
using NzbDrone.Core.History;
|
using NzbDrone.Core.History;
|
||||||
|
using NzbDrone.Core.Music;
|
||||||
|
|
||||||
namespace Lidarr.Api.V1.History
|
namespace Lidarr.Api.V1.History
|
||||||
{
|
{
|
||||||
|
@ -22,16 +23,19 @@ namespace Lidarr.Api.V1.History
|
||||||
private readonly ICustomFormatCalculationService _formatCalculator;
|
private readonly ICustomFormatCalculationService _formatCalculator;
|
||||||
private readonly IUpgradableSpecification _upgradableSpecification;
|
private readonly IUpgradableSpecification _upgradableSpecification;
|
||||||
private readonly IFailedDownloadService _failedDownloadService;
|
private readonly IFailedDownloadService _failedDownloadService;
|
||||||
|
private readonly IArtistService _artistService;
|
||||||
|
|
||||||
public HistoryController(IHistoryService historyService,
|
public HistoryController(IHistoryService historyService,
|
||||||
ICustomFormatCalculationService formatCalculator,
|
ICustomFormatCalculationService formatCalculator,
|
||||||
IUpgradableSpecification upgradableSpecification,
|
IUpgradableSpecification upgradableSpecification,
|
||||||
IFailedDownloadService failedDownloadService)
|
IFailedDownloadService failedDownloadService,
|
||||||
|
IArtistService artistService)
|
||||||
{
|
{
|
||||||
_historyService = historyService;
|
_historyService = historyService;
|
||||||
_formatCalculator = formatCalculator;
|
_formatCalculator = formatCalculator;
|
||||||
_upgradableSpecification = upgradableSpecification;
|
_upgradableSpecification = upgradableSpecification;
|
||||||
_failedDownloadService = failedDownloadService;
|
_failedDownloadService = failedDownloadService;
|
||||||
|
_artistService = artistService;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected HistoryResource MapToResource(EntityHistory model, bool includeArtist, bool includeAlbum, bool includeTrack)
|
protected HistoryResource MapToResource(EntityHistory model, bool includeArtist, bool includeAlbum, bool includeTrack)
|
||||||
|
@ -101,12 +105,24 @@ namespace Lidarr.Api.V1.History
|
||||||
[HttpGet("artist")]
|
[HttpGet("artist")]
|
||||||
public List<HistoryResource> GetArtistHistory(int artistId, int? albumId = null, EntityHistoryEventType? eventType = null, bool includeArtist = false, bool includeAlbum = false, bool includeTrack = false)
|
public List<HistoryResource> GetArtistHistory(int artistId, int? albumId = null, EntityHistoryEventType? eventType = null, bool includeArtist = false, bool includeAlbum = false, bool includeTrack = false)
|
||||||
{
|
{
|
||||||
|
var artist = _artistService.GetArtist(artistId);
|
||||||
|
|
||||||
if (albumId.HasValue)
|
if (albumId.HasValue)
|
||||||
{
|
{
|
||||||
return _historyService.GetByAlbum(albumId.Value, eventType).Select(h => MapToResource(h, includeArtist, includeAlbum, includeTrack)).ToList();
|
return _historyService.GetByAlbum(albumId.Value, eventType).Select(h =>
|
||||||
|
{
|
||||||
|
h.Artist = artist;
|
||||||
|
|
||||||
|
return MapToResource(h, includeArtist, includeAlbum, includeTrack);
|
||||||
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return _historyService.GetByArtist(artistId, eventType).Select(h => MapToResource(h, includeArtist, includeAlbum, includeTrack)).ToList();
|
return _historyService.GetByArtist(artistId, eventType).Select(h =>
|
||||||
|
{
|
||||||
|
h.Artist = artist;
|
||||||
|
|
||||||
|
return MapToResource(h, includeArtist, includeAlbum, includeTrack);
|
||||||
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("failed/{id}")]
|
[HttpPost("failed/{id}")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue