Fix translator handler
Some checks failed
Build docker image / Build-Docker-Image (push) Has been cancelled

This commit is contained in:
2024-12-26 02:13:05 +01:00
parent d49d5339fe
commit 4f78a5cf82
2 changed files with 19 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
{ {
"db_name": "PostgreSQL", "db_name": "PostgreSQL",
"query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n 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>\",\n b.uploaded,\n COALESCE(\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ),\n ARRAY[]::author_type[]\n ) AS \"authors!: Vec<Author>\",\n COALESCE(\n (\n SELECT\n ARRAY_AGG(\n ROW(\n sequences.id,\n sequences.name\n )::sequence_type\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ),\n ARRAY[]::sequence_type[]\n ) AS \"sequences!: Vec<Sequence>\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\"\n FROM books b\n ", "query": "\n SELECT\n b.id,\n b.title,\n b.lang,\n b.file_type,\n b.year,\n 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>\",\n b.uploaded,\n COALESCE(\n (\n SELECT\n ARRAY_AGG(\n ROW(\n authors.id,\n authors.first_name,\n authors.last_name,\n authors.middle_name,\n EXISTS(\n SELECT * FROM author_annotations WHERE author = authors.id\n )\n )::author_type\n )\n FROM book_authors\n JOIN authors ON authors.id = book_authors.author\n WHERE book_authors.book = b.id\n ),\n ARRAY[]::author_type[]\n ) AS \"authors!: Vec<Author>\",\n COALESCE(\n (\n SELECT\n ARRAY_AGG(\n ROW(\n sequences.id,\n sequences.name\n )::sequence_type\n )\n FROM book_sequences\n JOIN sequences ON sequences.id = book_sequences.sequence\n WHERE book_sequences.book = b.id\n ),\n ARRAY[]::sequence_type[]\n ) AS \"sequences!: Vec<Sequence>\",\n EXISTS(\n SELECT * FROM book_annotations WHERE book = b.id\n ) AS \"annotation_exists!: bool\"\n FROM books b\n JOIN book_authors ba ON b.id = ba.book\n WHERE\n b.is_deleted = false\n AND ba.author = $1\n AND b.lang = ANY($2)\n OFFSET $3\n LIMIT $4\n ",
"describe": { "describe": {
"columns": [ "columns": [
{ {
@@ -113,7 +113,12 @@
} }
], ],
"parameters": { "parameters": {
"Left": [] "Left": [
"Int4",
"TextArray",
"Int8",
"Int8"
]
}, },
"nullable": [ "nullable": [
false, false,
@@ -128,5 +133,5 @@
null null
] ]
}, },
"hash": "e3d5b79f21d3df4fe7bb32123f80d106f6bc4d8acb13c472a656d83f8ef992ca" "hash": "71ddfa47ccbd71543a0ff402f9b077d7035ad35fb5e714f5d88357169b46b0fe"
} }

View File

@@ -125,7 +125,18 @@ async fn get_translated_books(
SELECT * FROM book_annotations WHERE book = b.id SELECT * FROM book_annotations WHERE book = b.id
) AS "annotation_exists!: bool" ) AS "annotation_exists!: bool"
FROM books b FROM books b
JOIN book_authors ba ON b.id = ba.book
WHERE
b.is_deleted = false
AND ba.author = $1
AND b.lang = ANY($2)
OFFSET $3
LIMIT $4
"#, "#,
translator_id,
&allowed_langs,
(pagination.page - 1) * pagination.size,
pagination.size
) )
.fetch_all(&db.0) .fetch_all(&db.0)
.await .await