mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2025-12-06 15:15:36 +01:00
Fix
This commit is contained in:
@@ -214,34 +214,40 @@ async fn get_author_books(
|
|||||||
b.year,
|
b.year,
|
||||||
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
||||||
b.uploaded,
|
b.uploaded,
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
authors.id,
|
ROW(
|
||||||
authors.first_name,
|
authors.id,
|
||||||
authors.last_name,
|
authors.first_name,
|
||||||
authors.middle_name,
|
authors.last_name,
|
||||||
EXISTS(
|
authors.middle_name,
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
EXISTS(
|
||||||
)
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
)::author_type
|
)
|
||||||
)
|
)::author_type
|
||||||
FROM translations
|
)
|
||||||
JOIN authors ON authors.id = translations.author
|
FROM translations
|
||||||
WHERE translations.book = b.id
|
JOIN authors ON authors.id = translations.author
|
||||||
|
WHERE translations.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
) AS "translators!: Vec<Author>",
|
) AS "translators!: Vec<Author>",
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
sequences.id,
|
ROW(
|
||||||
sequences.name
|
sequences.id,
|
||||||
)::sequence_type
|
sequences.name
|
||||||
)
|
)::sequence_type
|
||||||
FROM book_sequences
|
)
|
||||||
JOIN sequences ON sequences.id = book_sequences.sequence
|
FROM book_sequences
|
||||||
WHERE book_sequences.book = b.id
|
JOIN sequences ON sequences.id = book_sequences.sequence
|
||||||
|
WHERE book_sequences.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::sequence_type[]
|
||||||
) AS "sequences!: Vec<Sequence>",
|
) AS "sequences!: Vec<Sequence>",
|
||||||
EXISTS(
|
EXISTS(
|
||||||
SELECT * FROM book_annotations WHERE book = b.id
|
SELECT * FROM book_annotations WHERE book = b.id
|
||||||
|
|||||||
@@ -60,51 +60,60 @@ pub async fn get_books(
|
|||||||
b.year,
|
b.year,
|
||||||
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
||||||
b.uploaded,
|
b.uploaded,
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
authors.id,
|
ROW(
|
||||||
authors.first_name,
|
authors.id,
|
||||||
authors.last_name,
|
authors.first_name,
|
||||||
authors.middle_name,
|
authors.last_name,
|
||||||
EXISTS(
|
authors.middle_name,
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
EXISTS(
|
||||||
)
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
)::author_type
|
)
|
||||||
)
|
)::author_type
|
||||||
FROM book_authors
|
)
|
||||||
JOIN authors ON authors.id = book_authors.author
|
FROM book_authors
|
||||||
WHERE book_authors.book = b.id
|
JOIN authors ON authors.id = book_authors.author
|
||||||
|
WHERE book_authors.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
) AS "authors!: Vec<Author>",
|
) AS "authors!: Vec<Author>",
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
authors.id,
|
ROW(
|
||||||
authors.first_name,
|
authors.id,
|
||||||
authors.last_name,
|
authors.first_name,
|
||||||
authors.middle_name,
|
authors.last_name,
|
||||||
EXISTS(
|
authors.middle_name,
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
EXISTS(
|
||||||
)
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
)::author_type
|
)
|
||||||
)
|
)::author_type
|
||||||
FROM translations
|
)
|
||||||
JOIN authors ON authors.id = translations.author
|
FROM translations
|
||||||
WHERE translations.book = b.id
|
JOIN authors ON authors.id = translations.author
|
||||||
|
WHERE translations.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
) AS "translators!: Vec<Author>",
|
) AS "translators!: Vec<Author>",
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
sequences.id,
|
ROW(
|
||||||
sequences.name
|
sequences.id,
|
||||||
)::sequence_type
|
sequences.name
|
||||||
)
|
)::sequence_type
|
||||||
FROM book_sequences
|
)
|
||||||
JOIN sequences ON sequences.id = book_sequences.sequence
|
FROM book_sequences
|
||||||
WHERE book_sequences.book = b.id
|
JOIN sequences ON sequences.id = book_sequences.sequence
|
||||||
|
WHERE book_sequences.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::sequence_type[]
|
||||||
) AS "sequences!: Vec<Sequence>",
|
) AS "sequences!: Vec<Sequence>",
|
||||||
EXISTS(
|
EXISTS(
|
||||||
SELECT * FROM book_annotations WHERE book = b.id
|
SELECT * FROM book_annotations WHERE book = b.id
|
||||||
@@ -243,71 +252,83 @@ pub async fn get_random_book(
|
|||||||
b.year,
|
b.year,
|
||||||
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
||||||
b.uploaded,
|
b.uploaded,
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
authors.id,
|
|
||||||
authors.first_name,
|
|
||||||
authors.last_name,
|
|
||||||
authors.middle_name,
|
|
||||||
EXISTS(
|
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
|
||||||
)
|
|
||||||
)::author_type
|
|
||||||
)
|
|
||||||
FROM book_authors
|
|
||||||
JOIN authors ON authors.id = book_authors.author
|
|
||||||
WHERE book_authors.book = b.id
|
|
||||||
) AS "authors!: Vec<Author>",
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
ARRAY_AGG(
|
|
||||||
ROW(
|
|
||||||
authors.id,
|
|
||||||
authors.first_name,
|
|
||||||
authors.last_name,
|
|
||||||
authors.middle_name,
|
|
||||||
EXISTS(
|
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
|
||||||
)
|
|
||||||
)::author_type
|
|
||||||
)
|
|
||||||
FROM translations
|
|
||||||
JOIN authors ON authors.id = translations.author
|
|
||||||
WHERE translations.book = b.id
|
|
||||||
) AS "translators!: Vec<Author>",
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
ARRAY_AGG(
|
|
||||||
ROW(
|
|
||||||
sequences.id,
|
|
||||||
sequences.name
|
|
||||||
)::sequence_type
|
|
||||||
)
|
|
||||||
FROM book_sequences
|
|
||||||
JOIN sequences ON sequences.id = book_sequences.sequence
|
|
||||||
WHERE book_sequences.book = b.id
|
|
||||||
) AS "sequences!: Vec<Sequence>",
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
ARRAY_AGG(
|
|
||||||
ROW(
|
|
||||||
genres.id,
|
|
||||||
ROW(
|
ROW(
|
||||||
sources.id,
|
authors.id,
|
||||||
sources.name
|
authors.first_name,
|
||||||
)::source_type,
|
authors.last_name,
|
||||||
genres.remote_id,
|
authors.middle_name,
|
||||||
genres.code,
|
EXISTS(
|
||||||
genres.description,
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
genres.meta
|
)
|
||||||
)::genre_type
|
)::author_type
|
||||||
)
|
)
|
||||||
FROM book_genres
|
FROM book_authors
|
||||||
JOIN genres ON genres.id = book_genres.genre
|
JOIN authors ON authors.id = book_authors.author
|
||||||
JOIN sources ON sources.id = genres.source
|
WHERE book_authors.book = b.id
|
||||||
WHERE book_genres.book = b.id
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
|
) AS "authors!: Vec<Author>",
|
||||||
|
COALESCE(
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
ARRAY_AGG(
|
||||||
|
ROW(
|
||||||
|
authors.id,
|
||||||
|
authors.first_name,
|
||||||
|
authors.last_name,
|
||||||
|
authors.middle_name,
|
||||||
|
EXISTS(
|
||||||
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
|
)
|
||||||
|
)::author_type
|
||||||
|
)
|
||||||
|
FROM translations
|
||||||
|
JOIN authors ON authors.id = translations.author
|
||||||
|
WHERE translations.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
|
) AS "translators!: Vec<Author>",
|
||||||
|
COALESCE(
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
ARRAY_AGG(
|
||||||
|
ROW(
|
||||||
|
sequences.id,
|
||||||
|
sequences.name
|
||||||
|
)::sequence_type
|
||||||
|
)
|
||||||
|
FROM book_sequences
|
||||||
|
JOIN sequences ON sequences.id = book_sequences.sequence
|
||||||
|
WHERE book_sequences.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::sequence_type[]
|
||||||
|
) AS "sequences!: Vec<Sequence>",
|
||||||
|
COALESCE(
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
ARRAY_AGG(
|
||||||
|
ROW(
|
||||||
|
genres.id,
|
||||||
|
ROW(
|
||||||
|
sources.id,
|
||||||
|
sources.name
|
||||||
|
)::source_type,
|
||||||
|
genres.remote_id,
|
||||||
|
genres.code,
|
||||||
|
genres.description,
|
||||||
|
genres.meta
|
||||||
|
)::genre_type
|
||||||
|
)
|
||||||
|
FROM book_genres
|
||||||
|
JOIN genres ON genres.id = book_genres.genre
|
||||||
|
JOIN sources ON sources.id = genres.source
|
||||||
|
WHERE book_genres.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::genre_type[]
|
||||||
) AS "genres!: Vec<Genre>",
|
) AS "genres!: Vec<Genre>",
|
||||||
EXISTS(
|
EXISTS(
|
||||||
SELECT * FROM book_annotations WHERE book = b.id
|
SELECT * FROM book_annotations WHERE book = b.id
|
||||||
@@ -352,71 +373,83 @@ pub async fn get_remote_book(
|
|||||||
b.year,
|
b.year,
|
||||||
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
||||||
b.uploaded,
|
b.uploaded,
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
authors.id,
|
|
||||||
authors.first_name,
|
|
||||||
authors.last_name,
|
|
||||||
authors.middle_name,
|
|
||||||
EXISTS(
|
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
|
||||||
)
|
|
||||||
)::author_type
|
|
||||||
)
|
|
||||||
FROM book_authors
|
|
||||||
JOIN authors ON authors.id = book_authors.author
|
|
||||||
WHERE book_authors.book = b.id
|
|
||||||
) AS "authors!: Vec<Author>",
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
ARRAY_AGG(
|
|
||||||
ROW(
|
|
||||||
authors.id,
|
|
||||||
authors.first_name,
|
|
||||||
authors.last_name,
|
|
||||||
authors.middle_name,
|
|
||||||
EXISTS(
|
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
|
||||||
)
|
|
||||||
)::author_type
|
|
||||||
)
|
|
||||||
FROM translations
|
|
||||||
JOIN authors ON authors.id = translations.author
|
|
||||||
WHERE translations.book = b.id
|
|
||||||
) AS "translators!: Vec<Author>",
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
ARRAY_AGG(
|
|
||||||
ROW(
|
|
||||||
sequences.id,
|
|
||||||
sequences.name
|
|
||||||
)::sequence_type
|
|
||||||
)
|
|
||||||
FROM book_sequences
|
|
||||||
JOIN sequences ON sequences.id = book_sequences.sequence
|
|
||||||
WHERE book_sequences.book = b.id
|
|
||||||
) AS "sequences!: Vec<Sequence>",
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
ARRAY_AGG(
|
|
||||||
ROW(
|
|
||||||
genres.id,
|
|
||||||
ROW(
|
ROW(
|
||||||
sources.id,
|
authors.id,
|
||||||
sources.name
|
authors.first_name,
|
||||||
)::source_type,
|
authors.last_name,
|
||||||
remote_id,
|
authors.middle_name,
|
||||||
genres.code,
|
EXISTS(
|
||||||
genres.description,
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
genres.meta
|
)
|
||||||
)::genre_type
|
)::author_type
|
||||||
)
|
)
|
||||||
FROM book_genres
|
FROM book_authors
|
||||||
JOIN genres ON genres.id = book_genres.genre
|
JOIN authors ON authors.id = book_authors.author
|
||||||
JOIN sources ON sources.id = genres.source
|
WHERE book_authors.book = b.id
|
||||||
WHERE book_genres.book = b.id
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
|
) AS "authors!: Vec<Author>",
|
||||||
|
COALESCE(
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
ARRAY_AGG(
|
||||||
|
ROW(
|
||||||
|
authors.id,
|
||||||
|
authors.first_name,
|
||||||
|
authors.last_name,
|
||||||
|
authors.middle_name,
|
||||||
|
EXISTS(
|
||||||
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
|
)
|
||||||
|
)::author_type
|
||||||
|
)
|
||||||
|
FROM translations
|
||||||
|
JOIN authors ON authors.id = translations.author
|
||||||
|
WHERE translations.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
|
) AS "translators!: Vec<Author>",
|
||||||
|
COALESCE(
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
ARRAY_AGG(
|
||||||
|
ROW(
|
||||||
|
sequences.id,
|
||||||
|
sequences.name
|
||||||
|
)::sequence_type
|
||||||
|
)
|
||||||
|
FROM book_sequences
|
||||||
|
JOIN sequences ON sequences.id = book_sequences.sequence
|
||||||
|
WHERE book_sequences.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::sequence_type[]
|
||||||
|
) AS "sequences!: Vec<Sequence>",
|
||||||
|
COALESCE(
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
ARRAY_AGG(
|
||||||
|
ROW(
|
||||||
|
genres.id,
|
||||||
|
ROW(
|
||||||
|
sources.id,
|
||||||
|
sources.name
|
||||||
|
)::source_type,
|
||||||
|
remote_id,
|
||||||
|
genres.code,
|
||||||
|
genres.description,
|
||||||
|
genres.meta
|
||||||
|
)::genre_type
|
||||||
|
)
|
||||||
|
FROM book_genres
|
||||||
|
JOIN genres ON genres.id = book_genres.genre
|
||||||
|
JOIN sources ON sources.id = genres.source
|
||||||
|
WHERE book_genres.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::genre_type[]
|
||||||
) AS "genres!: Vec<Genre>",
|
) AS "genres!: Vec<Genre>",
|
||||||
EXISTS(
|
EXISTS(
|
||||||
SELECT * FROM book_annotations WHERE book = b.id
|
SELECT * FROM book_annotations WHERE book = b.id
|
||||||
@@ -491,51 +524,60 @@ pub async fn search_books(
|
|||||||
b.year,
|
b.year,
|
||||||
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
||||||
b.uploaded,
|
b.uploaded,
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
authors.id,
|
ROW(
|
||||||
authors.first_name,
|
authors.id,
|
||||||
authors.last_name,
|
authors.first_name,
|
||||||
authors.middle_name,
|
authors.last_name,
|
||||||
EXISTS(
|
authors.middle_name,
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
EXISTS(
|
||||||
)
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
)::author_type
|
)
|
||||||
)
|
)::author_type
|
||||||
FROM book_authors
|
)
|
||||||
JOIN authors ON authors.id = book_authors.author
|
FROM book_authors
|
||||||
WHERE book_authors.book = b.id
|
JOIN authors ON authors.id = book_authors.author
|
||||||
|
WHERE book_authors.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
) AS "authors!: Vec<Author>",
|
) AS "authors!: Vec<Author>",
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
authors.id,
|
ROW(
|
||||||
authors.first_name,
|
authors.id,
|
||||||
authors.last_name,
|
authors.first_name,
|
||||||
authors.middle_name,
|
authors.last_name,
|
||||||
EXISTS(
|
authors.middle_name,
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
EXISTS(
|
||||||
)
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
)::author_type
|
)
|
||||||
)
|
)::author_type
|
||||||
FROM translations
|
)
|
||||||
JOIN authors ON authors.id = translations.author
|
FROM translations
|
||||||
WHERE translations.book = b.id
|
JOIN authors ON authors.id = translations.author
|
||||||
|
WHERE translations.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
) AS "translators!: Vec<Author>",
|
) AS "translators!: Vec<Author>",
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
sequences.id,
|
ROW(
|
||||||
sequences.name
|
sequences.id,
|
||||||
)::sequence_type
|
sequences.name
|
||||||
)
|
)::sequence_type
|
||||||
FROM book_sequences
|
)
|
||||||
JOIN sequences ON sequences.id = book_sequences.sequence
|
FROM book_sequences
|
||||||
WHERE book_sequences.book = b.id
|
JOIN sequences ON sequences.id = book_sequences.sequence
|
||||||
|
WHERE book_sequences.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::sequence_type[]
|
||||||
) AS "sequences!: Vec<Sequence>",
|
) AS "sequences!: Vec<Sequence>",
|
||||||
EXISTS(
|
EXISTS(
|
||||||
SELECT * FROM book_annotations WHERE book = b.id
|
SELECT * FROM book_annotations WHERE book = b.id
|
||||||
@@ -573,71 +615,83 @@ pub async fn get_book(db: Database, Path(book_id): Path<i32>) -> impl IntoRespon
|
|||||||
b.year,
|
b.year,
|
||||||
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
||||||
b.uploaded,
|
b.uploaded,
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
authors.id,
|
|
||||||
authors.first_name,
|
|
||||||
authors.last_name,
|
|
||||||
authors.middle_name,
|
|
||||||
EXISTS(
|
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
|
||||||
)
|
|
||||||
)::author_type
|
|
||||||
)
|
|
||||||
FROM book_authors
|
|
||||||
JOIN authors ON authors.id = book_authors.author
|
|
||||||
WHERE book_authors.book = b.id
|
|
||||||
) AS "authors!: Vec<Author>",
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
ARRAY_AGG(
|
|
||||||
ROW(
|
|
||||||
authors.id,
|
|
||||||
authors.first_name,
|
|
||||||
authors.last_name,
|
|
||||||
authors.middle_name,
|
|
||||||
EXISTS(
|
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
|
||||||
)
|
|
||||||
)::author_type
|
|
||||||
)
|
|
||||||
FROM translations
|
|
||||||
JOIN authors ON authors.id = translations.author
|
|
||||||
WHERE translations.book = b.id
|
|
||||||
) AS "translators!: Vec<Author>",
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
ARRAY_AGG(
|
|
||||||
ROW(
|
|
||||||
sequences.id,
|
|
||||||
sequences.name
|
|
||||||
)::sequence_type
|
|
||||||
)
|
|
||||||
FROM book_sequences
|
|
||||||
JOIN sequences ON sequences.id = book_sequences.sequence
|
|
||||||
WHERE book_sequences.book = b.id
|
|
||||||
) AS "sequences!: Vec<Sequence>",
|
|
||||||
(
|
|
||||||
SELECT
|
|
||||||
ARRAY_AGG(
|
|
||||||
ROW(
|
|
||||||
genres.id,
|
|
||||||
ROW(
|
ROW(
|
||||||
sources.id,
|
authors.id,
|
||||||
sources.name
|
authors.first_name,
|
||||||
)::source_type,
|
authors.last_name,
|
||||||
genres.remote_id,
|
authors.middle_name,
|
||||||
genres.code,
|
EXISTS(
|
||||||
genres.description,
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
genres.meta
|
)
|
||||||
)::genre_type
|
)::author_type
|
||||||
)
|
)
|
||||||
FROM book_genres
|
FROM book_authors
|
||||||
JOIN genres ON genres.id = book_genres.genre
|
JOIN authors ON authors.id = book_authors.author
|
||||||
JOIN sources ON sources.id = genres.source
|
WHERE book_authors.book = b.id
|
||||||
WHERE book_genres.book = b.id
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
|
) AS "authors!: Vec<Author>",
|
||||||
|
COALESCE(
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
ARRAY_AGG(
|
||||||
|
ROW(
|
||||||
|
authors.id,
|
||||||
|
authors.first_name,
|
||||||
|
authors.last_name,
|
||||||
|
authors.middle_name,
|
||||||
|
EXISTS(
|
||||||
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
|
)
|
||||||
|
)::author_type
|
||||||
|
)
|
||||||
|
FROM translations
|
||||||
|
JOIN authors ON authors.id = translations.author
|
||||||
|
WHERE translations.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
|
) AS "translators!: Vec<Author>",
|
||||||
|
COALESCE(
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
ARRAY_AGG(
|
||||||
|
ROW(
|
||||||
|
sequences.id,
|
||||||
|
sequences.name
|
||||||
|
)::sequence_type
|
||||||
|
)
|
||||||
|
FROM book_sequences
|
||||||
|
JOIN sequences ON sequences.id = book_sequences.sequence
|
||||||
|
WHERE book_sequences.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::sequence_type[]
|
||||||
|
) AS "sequences!: Vec<Sequence>",
|
||||||
|
COALESCE(
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
ARRAY_AGG(
|
||||||
|
ROW(
|
||||||
|
genres.id,
|
||||||
|
ROW(
|
||||||
|
sources.id,
|
||||||
|
sources.name
|
||||||
|
)::source_type,
|
||||||
|
genres.remote_id,
|
||||||
|
genres.code,
|
||||||
|
genres.description,
|
||||||
|
genres.meta
|
||||||
|
)::genre_type
|
||||||
|
)
|
||||||
|
FROM book_genres
|
||||||
|
JOIN genres ON genres.id = book_genres.genre
|
||||||
|
JOIN sources ON sources.id = genres.source
|
||||||
|
WHERE book_genres.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::genre_type[]
|
||||||
) AS "genres!: Vec<Genre>",
|
) AS "genres!: Vec<Genre>",
|
||||||
EXISTS(
|
EXISTS(
|
||||||
SELECT * FROM book_annotations WHERE book = b.id
|
SELECT * FROM book_annotations WHERE book = b.id
|
||||||
|
|||||||
@@ -213,39 +213,45 @@ async fn get_sequence_books(
|
|||||||
b.year,
|
b.year,
|
||||||
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
||||||
b.uploaded,
|
b.uploaded,
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
authors.id,
|
ROW(
|
||||||
authors.first_name,
|
authors.id,
|
||||||
authors.last_name,
|
authors.first_name,
|
||||||
authors.middle_name,
|
authors.last_name,
|
||||||
EXISTS(
|
authors.middle_name,
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
EXISTS(
|
||||||
)
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
)::author_type
|
)
|
||||||
)
|
)::author_type
|
||||||
FROM book_authors
|
)
|
||||||
JOIN authors ON authors.id = book_authors.author
|
FROM book_authors
|
||||||
WHERE book_authors.book = b.id
|
JOIN authors ON authors.id = book_authors.author
|
||||||
|
WHERE book_authors.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
) AS "authors!: Vec<Author>",
|
) AS "authors!: Vec<Author>",
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
authors.id,
|
ROW(
|
||||||
authors.first_name,
|
authors.id,
|
||||||
authors.last_name,
|
authors.first_name,
|
||||||
authors.middle_name,
|
authors.last_name,
|
||||||
EXISTS(
|
authors.middle_name,
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
EXISTS(
|
||||||
)
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
)::author_type
|
)
|
||||||
)
|
)::author_type
|
||||||
FROM translations
|
)
|
||||||
JOIN authors ON authors.id = translations.author
|
FROM translations
|
||||||
WHERE translations.book = b.id
|
JOIN authors ON authors.id = translations.author
|
||||||
|
WHERE translations.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
) AS "translators!: Vec<Author>",
|
) AS "translators!: Vec<Author>",
|
||||||
EXISTS(
|
EXISTS(
|
||||||
SELECT * FROM book_annotations WHERE book = b.id
|
SELECT * FROM book_annotations WHERE book = b.id
|
||||||
|
|||||||
@@ -86,34 +86,40 @@ async fn get_translated_books(
|
|||||||
b.year,
|
b.year,
|
||||||
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
CASE WHEN b.file_type = 'fb2' THEN ARRAY['fb2', 'epub', 'mobi', 'fb2zip']::text[] ELSE ARRAY[b.file_type]::text[] END AS "available_types!: Vec<String>",
|
||||||
b.uploaded,
|
b.uploaded,
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
authors.id,
|
ROW(
|
||||||
authors.first_name,
|
authors.id,
|
||||||
authors.last_name,
|
authors.first_name,
|
||||||
authors.middle_name,
|
authors.last_name,
|
||||||
EXISTS(
|
authors.middle_name,
|
||||||
SELECT * FROM author_annotations WHERE author = authors.id
|
EXISTS(
|
||||||
)
|
SELECT * FROM author_annotations WHERE author = authors.id
|
||||||
)::author_type
|
)
|
||||||
)
|
)::author_type
|
||||||
FROM book_authors
|
)
|
||||||
JOIN authors ON authors.id = book_authors.author
|
FROM book_authors
|
||||||
WHERE book_authors.book = b.id
|
JOIN authors ON authors.id = book_authors.author
|
||||||
|
WHERE book_authors.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::author_type[]
|
||||||
) AS "authors!: Vec<Author>",
|
) AS "authors!: Vec<Author>",
|
||||||
(
|
COALESCE(
|
||||||
SELECT
|
(
|
||||||
ARRAY_AGG(
|
SELECT
|
||||||
ROW(
|
ARRAY_AGG(
|
||||||
sequences.id,
|
ROW(
|
||||||
sequences.name
|
sequences.id,
|
||||||
)::sequence_type
|
sequences.name
|
||||||
)
|
)::sequence_type
|
||||||
FROM book_sequences
|
)
|
||||||
JOIN sequences ON sequences.id = book_sequences.sequence
|
FROM book_sequences
|
||||||
WHERE book_sequences.book = b.id
|
JOIN sequences ON sequences.id = book_sequences.sequence
|
||||||
|
WHERE book_sequences.book = b.id
|
||||||
|
),
|
||||||
|
ARRAY[]::sequence_type[]
|
||||||
) AS "sequences!: Vec<Sequence>",
|
) AS "sequences!: Vec<Sequence>",
|
||||||
EXISTS(
|
EXISTS(
|
||||||
SELECT * FROM book_annotations WHERE book = b.id
|
SELECT * FROM book_annotations WHERE book = b.id
|
||||||
|
|||||||
Reference in New Issue
Block a user