From 8a49903ecaf087a61530bdd1fc5797f00a0284d6 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 15 Nov 2024 20:53:59 +0100 Subject: [PATCH] `core`: Support meta titles --- acrate-core/src/meta.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/acrate-core/src/meta.rs b/acrate-core/src/meta.rs index a5b4d2a..bcfd200 100644 --- a/acrate-core/src/meta.rs +++ b/acrate-core/src/meta.rs @@ -22,6 +22,7 @@ pub struct MetaLink { pub rel: String, pub type_: Option, pub href: Option, + pub template: Option, } #[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable, Associations)] @@ -34,6 +35,16 @@ pub struct MetaLinkProperty { pub value: Option, } +#[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable, Associations)] +#[diesel(belongs_to(MetaLink))] +#[diesel(table_name = schema::meta_link_titles)] +pub struct MetaLinkTitle { + pub id: Uuid, + pub meta_link_id: Uuid, + pub language: String, + pub value: String, +} + #[derive(Debug, Queryable, QueryableByName, Identifiable, Selectable, Insertable)] #[diesel(table_name = schema::meta_properties)] pub struct MetaProperty { @@ -44,7 +55,6 @@ pub struct MetaProperty { pub value: Option, } - impl MetaAlias { pub async fn query_matching(conn: &mut AsyncPgConnection, doc: &str, subject: &str) -> QueryResult> { use diesel::prelude::*; @@ -88,6 +98,15 @@ impl MetaLink { .load(conn) .await } + + pub async fn query_titles(&self, conn: &mut AsyncPgConnection) -> QueryResult> { + use diesel::prelude::*; + use diesel_async::RunQueryDsl; + + MetaLinkTitle::belonging_to(self) + .load(conn) + .await + } } impl MetaProperty {