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.
52 lines
2.0 KiB
52 lines
2.0 KiB
using Microsoft.AspNetCore.Mvc;
|
|
using NzbDrone.Core.AuthorStats;
|
|
using NzbDrone.Core.Books;
|
|
using NzbDrone.Core.Datastore;
|
|
using NzbDrone.Core.DecisionEngine.Specifications;
|
|
using NzbDrone.Core.MediaCover;
|
|
using NzbDrone.SignalR;
|
|
using Readarr.Api.V1.Books;
|
|
using Readarr.Http;
|
|
using Readarr.Http.Extensions;
|
|
|
|
namespace Readarr.Api.V1.Wanted
|
|
{
|
|
[V1ApiController("wanted/missing")]
|
|
public class MissingController : BookControllerWithSignalR
|
|
{
|
|
public MissingController(IBookService bookService,
|
|
ISeriesBookLinkService seriesBookLinkService,
|
|
IAuthorStatisticsService authorStatisticsService,
|
|
IMapCoversToLocal coverMapper,
|
|
IUpgradableSpecification upgradableSpecification,
|
|
IBroadcastSignalRMessage signalRBroadcaster)
|
|
: base(bookService, seriesBookLinkService, authorStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster)
|
|
{
|
|
}
|
|
|
|
[HttpGet]
|
|
public PagingResource<BookResource> GetMissingBooks([FromQuery] PagingRequestResource paging, bool includeAuthor = false, bool monitored = true)
|
|
{
|
|
var pagingResource = new PagingResource<BookResource>(paging);
|
|
var pagingSpec = new PagingSpec<Book>
|
|
{
|
|
Page = pagingResource.Page,
|
|
PageSize = pagingResource.PageSize,
|
|
SortKey = pagingResource.SortKey,
|
|
SortDirection = pagingResource.SortDirection
|
|
};
|
|
|
|
if (monitored)
|
|
{
|
|
pagingSpec.FilterExpressions.Add(v => v.Monitored == false || v.Author.Value.Monitored == false);
|
|
}
|
|
else
|
|
{
|
|
pagingSpec.FilterExpressions.Add(v => v.Monitored == true && v.Author.Value.Monitored == true);
|
|
}
|
|
|
|
return pagingSpec.ApplyToPage(_bookService.BooksWithoutFiles, v => MapToResource(v, includeAuthor));
|
|
}
|
|
}
|
|
}
|