mirror of
https://github.com/Readarr/Readarr
synced 2026-02-13 02:03:06 +01:00
Fixed: Add ForeignEditionId to books endpoint
This commit is contained in:
parent
b9f1882a57
commit
27e498bb14
6 changed files with 11 additions and 5 deletions
|
|
@ -166,6 +166,7 @@ public void get_last_books_should_return_next_book()
|
|||
|
||||
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 @@ public Book()
|
|||
// 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 @@ public override string ToString()
|
|||
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 @@ public override void UseDbFieldsFrom(Book other)
|
|||
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 @@ public static void Map()
|
|||
|
||||
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 @@ public class ReadarrBook
|
|||
{
|
||||
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 @@ public override IList<ImportListItemInfo> Fetch()
|
|||
{
|
||||
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 @@ public class BookResource : RestResource
|
|||
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 @@ public static BookResource ToResource(this Book model)
|
|||
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 @@ public static Book ToModel(this BookResource resource)
|
|||
{
|
||||
Id = resource.Id,
|
||||
ForeignBookId = resource.ForeignBookId,
|
||||
ForeignEditionId = resource.ForeignEditionId,
|
||||
TitleSlug = resource.TitleSlug,
|
||||
Title = resource.Title,
|
||||
Monitored = resource.Monitored,
|
||||
|
|
|
|||
Loading…
Reference in a new issue