mirror of
https://github.com/Readarr/Readarr
synced 2025-12-15 21:02:40 +01:00
Fixed: Bad SQL queries getting files for book
This commit is contained in:
parent
190c4059cc
commit
0d3798b8b1
1 changed files with 8 additions and 4 deletions
|
|
@ -70,7 +70,8 @@ public List<Book> GetBooksForRefresh(int authorMetadataId, IEnumerable<string> f
|
|||
public List<Book> GetBooksByFileIds(IEnumerable<int> fileIds)
|
||||
{
|
||||
return Query(new SqlBuilder()
|
||||
.Join<Book, BookFile>((l, r) => l.Id == r.EditionId)
|
||||
.Join<Book, Edition>((b, e) => b.Id == e.BookId)
|
||||
.Join<Edition, BookFile>((l, r) => l.Id == r.EditionId)
|
||||
.Where<BookFile>(f => fileIds.Contains(f.Id)))
|
||||
.DistinctBy(x => x.Id)
|
||||
.ToList();
|
||||
|
|
@ -90,7 +91,8 @@ public Book FindBySlug(string titleSlug)
|
|||
#pragma warning disable CS0472
|
||||
private SqlBuilder AlbumsWithoutFilesBuilder(DateTime currentTime) => Builder()
|
||||
.Join<Book, Author>((l, r) => l.AuthorMetadataId == r.AuthorMetadataId)
|
||||
.LeftJoin<Book, BookFile>((t, f) => t.Id == f.EditionId)
|
||||
.Join<Book, Edition>((b, e) => b.Id == e.BookId)
|
||||
.LeftJoin<Edition, BookFile>((t, f) => t.Id == f.EditionId)
|
||||
.Where<BookFile>(f => f.Id == null)
|
||||
.Where<Book>(a => a.ReleaseDate <= currentTime);
|
||||
#pragma warning restore CS0472
|
||||
|
|
@ -107,7 +109,8 @@ public PagingSpec<Book> BooksWithoutFiles(PagingSpec<Book> pagingSpec)
|
|||
|
||||
private SqlBuilder AlbumsWhereCutoffUnmetBuilder(List<QualitiesBelowCutoff> qualitiesBelowCutoff) => Builder()
|
||||
.Join<Book, Author>((l, r) => l.AuthorMetadataId == r.AuthorMetadataId)
|
||||
.Join<Book, BookFile>((t, f) => t.Id == f.EditionId)
|
||||
.Join<Book, Edition>((b, e) => b.Id == e.BookId)
|
||||
.LeftJoin<Edition, BookFile>((t, f) => t.Id == f.EditionId)
|
||||
.Where(BuildQualityCutoffWhereClause(qualitiesBelowCutoff));
|
||||
|
||||
private string BuildQualityCutoffWhereClause(List<QualitiesBelowCutoff> qualitiesBelowCutoff)
|
||||
|
|
@ -193,7 +196,8 @@ public Book FindByTitle(int authorMetadataId, string title)
|
|||
public List<Book> GetAuthorBooksWithFiles(Author author)
|
||||
{
|
||||
return Query(Builder()
|
||||
.Join<Book, BookFile>((t, f) => t.Id == f.EditionId)
|
||||
.Join<Book, Edition>((b, e) => b.Id == e.BookId)
|
||||
.Join<Edition, BookFile>((t, f) => t.Id == f.EditionId)
|
||||
.Where<Book>(x => x.AuthorMetadataId == author.AuthorMetadataId));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue