You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
2.2 KiB
58 lines
2.2 KiB
7 years ago
|
using System.Linq;
|
||
7 years ago
|
using Lidarr.Api.V1.Albums;
|
||
7 years ago
|
using Lidarr.Http;
|
||
7 years ago
|
using Lidarr.Http.Extensions;
|
||
3 years ago
|
using Microsoft.AspNetCore.Mvc;
|
||
5 years ago
|
using NzbDrone.Core.ArtistStats;
|
||
|
using NzbDrone.Core.Datastore;
|
||
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
||
6 years ago
|
using NzbDrone.Core.MediaCover;
|
||
5 years ago
|
using NzbDrone.Core.Music;
|
||
|
using NzbDrone.SignalR;
|
||
7 years ago
|
|
||
7 years ago
|
namespace Lidarr.Api.V1.Wanted
|
||
7 years ago
|
{
|
||
3 years ago
|
[V1ApiController("wanted/cutoff")]
|
||
|
public class CutoffController : AlbumControllerWithSignalR
|
||
7 years ago
|
{
|
||
7 years ago
|
private readonly IAlbumCutoffService _albumCutoffService;
|
||
7 years ago
|
|
||
3 years ago
|
public CutoffController(IAlbumCutoffService albumCutoffService,
|
||
7 years ago
|
IAlbumService albumService,
|
||
|
IArtistStatisticsService artistStatisticsService,
|
||
6 years ago
|
IMapCoversToLocal coverMapper,
|
||
7 years ago
|
IUpgradableSpecification upgradableSpecification,
|
||
|
IBroadcastSignalRMessage signalRBroadcaster)
|
||
3 years ago
|
: base(albumService, artistStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster)
|
||
7 years ago
|
{
|
||
7 years ago
|
_albumCutoffService = albumCutoffService;
|
||
7 years ago
|
}
|
||
|
|
||
3 years ago
|
[HttpGet]
|
||
|
public PagingResource<AlbumResource> GetCutoffUnmetAlbums(bool includeArtist = false)
|
||
7 years ago
|
{
|
||
3 years ago
|
var pagingResource = Request.ReadPagingResourceFromRequest<AlbumResource>();
|
||
7 years ago
|
var pagingSpec = new PagingSpec<Album>
|
||
|
{
|
||
|
Page = pagingResource.Page,
|
||
|
PageSize = pagingResource.PageSize,
|
||
|
SortKey = pagingResource.SortKey,
|
||
|
SortDirection = pagingResource.SortDirection
|
||
|
};
|
||
|
|
||
7 years ago
|
var filter = pagingResource.Filters.FirstOrDefault(f => f.Key == "monitored");
|
||
7 years ago
|
|
||
7 years ago
|
if (filter != null && filter.Value == "false")
|
||
7 years ago
|
{
|
||
6 years ago
|
pagingSpec.FilterExpressions.Add(v => v.Monitored == false || v.Artist.Value.Monitored == false);
|
||
7 years ago
|
}
|
||
|
else
|
||
|
{
|
||
6 years ago
|
pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Artist.Value.Monitored == true);
|
||
7 years ago
|
}
|
||
|
|
||
3 years ago
|
return pagingSpec.ApplyToPage(_albumCutoffService.AlbumsWhereCutoffUnmet, v => MapToResource(v, includeArtist));
|
||
7 years ago
|
}
|
||
|
}
|
||
|
}
|