mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-18 21:34:28 -04:00
New: Show series info in author books table and book details
This commit is contained in:
@@ -37,6 +37,7 @@ namespace Readarr.Api.V1.Books
|
||||
IBookService bookService,
|
||||
IAddBookService addBookService,
|
||||
IEditionService editionService,
|
||||
ISeriesBookLinkService seriesBookLinkService,
|
||||
IAuthorStatisticsService authorStatisticsService,
|
||||
IMapCoversToLocal coverMapper,
|
||||
IUpgradableSpecification upgradableSpecification,
|
||||
@@ -44,7 +45,7 @@ namespace Readarr.Api.V1.Books
|
||||
QualityProfileExistsValidator qualityProfileExistsValidator,
|
||||
MetadataProfileExistsValidator metadataProfileExistsValidator)
|
||||
|
||||
: base(bookService, authorStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster)
|
||||
: base(bookService, seriesBookLinkService, authorStatisticsService, coverMapper, upgradableSpecification, signalRBroadcaster)
|
||||
{
|
||||
_authorService = authorService;
|
||||
_editionService = editionService;
|
||||
|
||||
@@ -14,18 +14,21 @@ namespace Readarr.Api.V1.Books
|
||||
public abstract class BookModuleWithSignalR : ReadarrRestModuleWithSignalR<BookResource, Book>
|
||||
{
|
||||
protected readonly IBookService _bookService;
|
||||
protected readonly ISeriesBookLinkService _seriesBookLinkService;
|
||||
protected readonly IAuthorStatisticsService _authorStatisticsService;
|
||||
protected readonly IUpgradableSpecification _qualityUpgradableSpecification;
|
||||
protected readonly IMapCoversToLocal _coverMapper;
|
||||
|
||||
protected BookModuleWithSignalR(IBookService bookService,
|
||||
IAuthorStatisticsService authorStatisticsService,
|
||||
IMapCoversToLocal coverMapper,
|
||||
IUpgradableSpecification qualityUpgradableSpecification,
|
||||
IBroadcastSignalRMessage signalRBroadcaster)
|
||||
ISeriesBookLinkService seriesBookLinkService,
|
||||
IAuthorStatisticsService authorStatisticsService,
|
||||
IMapCoversToLocal coverMapper,
|
||||
IUpgradableSpecification qualityUpgradableSpecification,
|
||||
IBroadcastSignalRMessage signalRBroadcaster)
|
||||
: base(signalRBroadcaster)
|
||||
{
|
||||
_bookService = bookService;
|
||||
_seriesBookLinkService = seriesBookLinkService;
|
||||
_authorStatisticsService = authorStatisticsService;
|
||||
_coverMapper = coverMapper;
|
||||
_qualityUpgradableSpecification = qualityUpgradableSpecification;
|
||||
@@ -75,6 +78,22 @@ namespace Readarr.Api.V1.Books
|
||||
|
||||
protected List<BookResource> MapToResource(List<Book> books, bool includeAuthor)
|
||||
{
|
||||
var seriesLinks = _seriesBookLinkService.GetLinksByBook(books.Select(x => x.Id).ToList())
|
||||
.GroupBy(x => x.BookId)
|
||||
.ToDictionary(x => x.Key, y => y.ToList());
|
||||
|
||||
foreach (var book in books)
|
||||
{
|
||||
if (seriesLinks.TryGetValue(book.Id, out var links))
|
||||
{
|
||||
book.SeriesLinks = links;
|
||||
}
|
||||
else
|
||||
{
|
||||
book.SeriesLinks = new List<SeriesBookLink>();
|
||||
}
|
||||
}
|
||||
|
||||
var result = books.ToResource();
|
||||
|
||||
if (includeAuthor)
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Books;
|
||||
using NzbDrone.Core.MediaCover;
|
||||
using Readarr.Api.V1.Author;
|
||||
@@ -13,6 +14,7 @@ namespace Readarr.Api.V1.Books
|
||||
public class BookResource : RestResource
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string SeriesTitle { get; set; }
|
||||
public string Disambiguation { get; set; }
|
||||
public string Overview { get; set; }
|
||||
public int AuthorId { get; set; }
|
||||
@@ -60,6 +62,7 @@ namespace Readarr.Api.V1.Books
|
||||
PageCount = selectedEdition?.PageCount ?? 0,
|
||||
Genres = model.Genres,
|
||||
Title = selectedEdition?.Title ?? model.Title,
|
||||
SeriesTitle = model.SeriesLinks.Value.Select(x => x.Series.Value.Title + (x.Position.IsNotNullOrWhiteSpace() ? $" #{x.Position}" : string.Empty)).ConcatToString("; "),
|
||||
Disambiguation = selectedEdition?.Disambiguation,
|
||||
Overview = selectedEdition?.Overview,
|
||||
Images = selectedEdition?.Images ?? new List<MediaCover>(),
|
||||
|
||||
Reference in New Issue
Block a user