mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-02-09 17:35:15 +00:00
Fixed: Add ForeignEditionId to books endpoint
This commit is contained in:
@@ -166,6 +166,7 @@ namespace NzbDrone.Core.Test.MusicTests.BookRepositoryTests
|
||||
|
||||
private EquivalencyAssertionOptions<Book> BookComparerOptions(EquivalencyAssertionOptions<Book> opts) => opts.ComparingByMembers<Book>()
|
||||
.Excluding(ctx => ctx.SelectedMemberInfo.MemberType.IsGenericType && ctx.SelectedMemberInfo.MemberType.GetGenericTypeDefinition() == typeof(LazyLoaded<>))
|
||||
.Excluding(x => x.AuthorId);
|
||||
.Excluding(x => x.AuthorId)
|
||||
.Excluding(x => x.ForeignEditionId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace NzbDrone.Core.Books
|
||||
// These are metadata entries
|
||||
public int AuthorMetadataId { get; set; }
|
||||
public string ForeignBookId { get; set; }
|
||||
public string ForeignEditionId { get; set; }
|
||||
public string TitleSlug { get; set; }
|
||||
public string Title { get; set; }
|
||||
public DateTime? ReleaseDate { get; set; }
|
||||
@@ -71,6 +72,7 @@ namespace NzbDrone.Core.Books
|
||||
public override void UseMetadataFrom(Book other)
|
||||
{
|
||||
ForeignBookId = other.ForeignBookId;
|
||||
ForeignEditionId = other.ForeignEditionId;
|
||||
TitleSlug = other.TitleSlug;
|
||||
Title = other.Title;
|
||||
ReleaseDate = other.ReleaseDate;
|
||||
@@ -95,6 +97,7 @@ namespace NzbDrone.Core.Books
|
||||
public override void ApplyChanges(Book other)
|
||||
{
|
||||
ForeignBookId = other.ForeignBookId;
|
||||
ForeignEditionId = other.ForeignEditionId;
|
||||
AddOptions = other.AddOptions;
|
||||
Monitored = other.Monitored;
|
||||
AnyEditionOk = other.AnyEditionOk;
|
||||
|
||||
@@ -135,6 +135,7 @@ namespace NzbDrone.Core.Datastore
|
||||
|
||||
Mapper.Entity<Book>("Books").RegisterModel()
|
||||
.Ignore(x => x.AuthorId)
|
||||
.Ignore(x => x.ForeignEditionId)
|
||||
.HasOne(r => r.AuthorMetadata, r => r.AuthorMetadataId)
|
||||
.LazyLoad(x => x.BookFiles,
|
||||
(db, book) => db.Query<BookFile>(new SqlBuilder(db.DatabaseType)
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace NzbDrone.Core.ImportLists.Readarr
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string ForeignBookId { get; set; }
|
||||
public string ForeignEditionId { get; set; }
|
||||
public string Overview { get; set; }
|
||||
public List<MediaCover.MediaCover> Images { get; set; }
|
||||
public bool Monitored { get; set; }
|
||||
|
||||
@@ -68,10 +68,7 @@ namespace NzbDrone.Core.ImportLists.Readarr
|
||||
{
|
||||
BookGoodreadsId = remoteBook.ForeignBookId,
|
||||
Book = remoteBook.Title,
|
||||
|
||||
// ToDo: Fix me. Edition is no longer in the book resource; rethink edition logic
|
||||
// Bandaid fix for now...This will cause the imported book to possibly not be same edition as the source
|
||||
// EditionGoodreadsId = remoteBook.Editions.Single(x => x.Monitored).ForeignEditionId,
|
||||
EditionGoodreadsId = remoteBook.ForeignEditionId,
|
||||
Author = remoteAuthor.AuthorName,
|
||||
AuthorGoodreadsId = remoteAuthor.ForeignAuthorId
|
||||
});
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace Readarr.Api.V1.Books
|
||||
public string Overview { get; set; }
|
||||
public int AuthorId { get; set; }
|
||||
public string ForeignBookId { get; set; }
|
||||
public string ForeignEditionId { get; set; }
|
||||
public string TitleSlug { get; set; }
|
||||
public bool Monitored { get; set; }
|
||||
public bool AnyEditionOk { get; set; }
|
||||
@@ -62,6 +63,7 @@ namespace Readarr.Api.V1.Books
|
||||
Id = model.Id,
|
||||
AuthorId = model.AuthorId,
|
||||
ForeignBookId = model.ForeignBookId,
|
||||
ForeignEditionId = model.Editions?.Value?.SingleOrDefault(x => x.Monitored)?.ForeignEditionId,
|
||||
TitleSlug = model.TitleSlug,
|
||||
Monitored = model.Monitored,
|
||||
AnyEditionOk = model.AnyEditionOk,
|
||||
@@ -92,6 +94,7 @@ namespace Readarr.Api.V1.Books
|
||||
{
|
||||
Id = resource.Id,
|
||||
ForeignBookId = resource.ForeignBookId,
|
||||
ForeignEditionId = resource.ForeignEditionId,
|
||||
TitleSlug = resource.TitleSlug,
|
||||
Title = resource.Title,
|
||||
Monitored = resource.Monitored,
|
||||
|
||||
Reference in New Issue
Block a user