This commit is contained in:
2024-12-26 00:03:51 +01:00
parent f938516f65
commit 52ab9b361d
24 changed files with 650 additions and 650 deletions

View File

@@ -23,7 +23,7 @@ pub struct AuthorBook {
pub available_types: Vec<String>,
#[serde(serialize_with = "naive_date_serializer::serialize")]
pub uploaded: NaiveDate,
pub translators: Vec<Author>,
pub sequences: Vec<Sequence>,
pub translators: sqlx::types::Json<Vec<Author>>,
pub sequences: sqlx::types::Json<Vec<Sequence>>,
pub annotation_exists: bool,
}

View File

@@ -81,8 +81,8 @@ pub struct Book {
pub available_types: Vec<String>,
#[serde(serialize_with = "naive_date_serializer::serialize")]
pub uploaded: NaiveDate,
pub authors: Vec<Author>,
pub translators: Vec<Author>,
pub sequences: Vec<Sequence>,
pub authors: sqlx::types::Json<Vec<Author>>,
pub translators: sqlx::types::Json<Vec<Author>>,
pub sequences: sqlx::types::Json<Vec<Sequence>>,
pub annotation_exists: bool,
}

View File

@@ -20,8 +20,8 @@ pub struct SequenceBook {
pub available_types: Vec<String>,
#[serde(serialize_with = "naive_date_serializer::serialize")]
pub uploaded: NaiveDate,
pub authors: Vec<Author>,
pub translators: Vec<Author>,
pub authors: sqlx::types::Json<Vec<Author>>,
pub translators: sqlx::types::Json<Vec<Author>>,
pub annotation_exists: bool,
pub position: i32,
}

View File

@@ -15,7 +15,7 @@ pub struct TranslatorBook {
pub available_types: Vec<String>,
#[serde(serialize_with = "naive_date_serializer::serialize")]
pub uploaded: NaiveDate,
pub authors: Vec<Author>,
pub sequences: Vec<Sequence>,
pub authors: sqlx::types::Json<Vec<Author>>,
pub sequences: sqlx::types::Json<Vec<Sequence>>,
pub annotation_exists: bool,
}

View File

@@ -216,8 +216,8 @@ async fn get_author_books(
b.uploaded,
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -233,8 +233,8 @@ async fn get_author_books(
) AS "translators!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', sequences.id,
'name', sequences.name
)

View File

@@ -62,8 +62,8 @@ pub async fn get_books(
b.uploaded,
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -79,8 +79,8 @@ pub async fn get_books(
) AS "authors!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -96,8 +96,8 @@ pub async fn get_books(
) AS "translators!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', sequences.id,
'name', sequences.name
)
@@ -111,7 +111,7 @@ pub async fn get_books(
) AS "annotation_exists!: bool",
(
SELECT
JSON_BUILD_OBJECT(
JSONB_BUILD_OBJECT(
'id', sources.id,
'name', sources.name
)
@@ -245,8 +245,8 @@ pub async fn get_random_book(
b.uploaded,
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -262,8 +262,8 @@ pub async fn get_random_book(
) AS "authors!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -279,8 +279,8 @@ pub async fn get_random_book(
) AS "translators!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', sequences.id,
'name', sequences.name
)
@@ -291,13 +291,13 @@ pub async fn get_random_book(
) AS "sequences!: Vec<Sequence>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', genres.id,
'code', genres.code,
'description', genres.description,
'meta', genres.meta,
'source', JSON_BUILD_OBJECT(
'source', JSONB_BUILD_OBJECT(
'id', sources.id,
'name', sources.name
)
@@ -313,7 +313,7 @@ pub async fn get_random_book(
) AS "annotation_exists!: bool",
(
SELECT
JSON_BUILD_OBJECT(
JSONB_BUILD_OBJECT(
'id', sources.id,
'name', sources.name
)
@@ -353,8 +353,8 @@ pub async fn get_remote_book(
b.uploaded,
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -370,8 +370,8 @@ pub async fn get_remote_book(
) AS "authors!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -387,8 +387,8 @@ pub async fn get_remote_book(
) AS "translators!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', sequences.id,
'name', sequences.name
)
@@ -399,13 +399,13 @@ pub async fn get_remote_book(
) AS "sequences!: Vec<Sequence>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', genres.id,
'code', genres.code,
'description', genres.description,
'meta', genres.meta,
'source', JSON_BUILD_OBJECT(
'source', JSONB_BUILD_OBJECT(
'id', sources.id,
'name', sources.name
)
@@ -421,7 +421,7 @@ pub async fn get_remote_book(
) AS "annotation_exists!: bool",
(
SELECT
JSON_BUILD_OBJECT(
JSONB_BUILD_OBJECT(
'id', sources.id,
'name', sources.name
)
@@ -491,8 +491,8 @@ pub async fn search_books(
b.uploaded,
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -508,8 +508,8 @@ pub async fn search_books(
) AS "authors!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -525,8 +525,8 @@ pub async fn search_books(
) AS "translators!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', sequences.id,
'name', sequences.name
)
@@ -573,8 +573,8 @@ pub async fn get_book(db: Database, Path(book_id): Path<i32>) -> impl IntoRespon
b.uploaded,
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -590,8 +590,8 @@ pub async fn get_book(db: Database, Path(book_id): Path<i32>) -> impl IntoRespon
) AS "authors!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -607,8 +607,8 @@ pub async fn get_book(db: Database, Path(book_id): Path<i32>) -> impl IntoRespon
) AS "translators!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', sequences.id,
'name', sequences.name
)
@@ -619,13 +619,13 @@ pub async fn get_book(db: Database, Path(book_id): Path<i32>) -> impl IntoRespon
) AS "sequences!: Vec<Sequence>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', genres.id,
'code', genres.code,
'description', genres.description,
'meta', genres.meta,
'source', JSON_BUILD_OBJECT(
'source', JSONB_BUILD_OBJECT(
'id', sources.id,
'name', sources.name
)
@@ -641,7 +641,7 @@ pub async fn get_book(db: Database, Path(book_id): Path<i32>) -> impl IntoRespon
) AS "annotation_exists!: bool",
(
SELECT
JSON_BUILD_OBJECT(
JSONB_BUILD_OBJECT(
'id', sources.id,
'name', sources.name
)

View File

@@ -39,7 +39,7 @@ pub async fn get_genres(
genres.meta,
(
SELECT
JSON_BUILD_OBJECT(
JSONB_BUILD_OBJECT(
'id', sources.id,
'name', sources.name
)
@@ -76,7 +76,7 @@ pub async fn get_genre_metas(db: Database) -> impl IntoResponse {
genres.meta,
(
SELECT
JSON_BUILD_OBJECT(
JSONB_BUILD_OBJECT(
'id', sources.id,
'name', sources.name
)

View File

@@ -215,8 +215,8 @@ async fn get_sequence_books(
b.uploaded,
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -232,8 +232,8 @@ async fn get_sequence_books(
) AS "authors!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,

View File

@@ -88,8 +88,8 @@ async fn get_translated_books(
b.uploaded,
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', authors.id,
'first_name', authors.first_name,
'last_name', authors.last_name,
@@ -105,8 +105,8 @@ async fn get_translated_books(
) AS "authors!: Vec<Author>",
(
SELECT
JSON_AGG(
JSON_BUILD_OBJECT(
JSONB_AGG(
JSONB_BUILD_OBJECT(
'id', sequences.id,
'name', sequences.name
)