diff --git a/deepwell/src/endpoints/page.rs b/deepwell/src/endpoints/page.rs index b31d10dc0e7..858854e9751 100644 --- a/deepwell/src/endpoints/page.rs +++ b/deepwell/src/endpoints/page.rs @@ -84,8 +84,8 @@ pub async fn page_get_score( info!("Getting score for page {reference:?} in site ID {site_id}"); let page_id = PageService::get_id(ctx, site_id, reference).await?; - let rating = ScoreService::score(ctx, page_id).await?; - Ok(GetPageScoreOutput { page_id, rating }) + let score = ScoreService::score(ctx, page_id).await?; + Ok(GetPageScoreOutput { page_id, score }) } pub async fn page_edit( diff --git a/deepwell/src/endpoints/parent.rs b/deepwell/src/endpoints/parent.rs index 80ce6f3077d..af8cc3b3ff2 100644 --- a/deepwell/src/endpoints/parent.rs +++ b/deepwell/src/endpoints/parent.rs @@ -22,8 +22,8 @@ use super::prelude::*; use crate::models::page_parent::Model as PageParentModel; use crate::services::page::GetPageReference; use crate::services::parent::{ - GetParentRelationships, ModifyParentOutput, ParentDescription, - ParentModifyDescription, RemoveParentOutput, + GetParentRelationships, ParentDescription, RemoveParentOutput, UpdateParents, + UpdateParentsOutput, }; use crate::web::Reference; @@ -108,8 +108,8 @@ pub async fn parent_get_all( let pages: Vec = PageService::get_pages(ctx, site_id, parents.as_slice()) .await? - .iter() - .map(|p| p.slug.clone()) + .into_iter() + .map(|p| p.slug) .collect(); Ok(pages) @@ -118,11 +118,11 @@ pub async fn parent_get_all( pub async fn parent_modify( ctx: &ServiceContext<'_>, params: Params<'static>, -) -> Result { - let input: ParentModifyDescription = params.parse()?; +) -> Result { + let input: UpdateParents = params.parse()?; info!( - "Modifying multiple parental relationship for child {:?} in site ID {}", + "Updating multiple parental relationships for child {:?} in site ID {}", input.child, input.site_id, ); @@ -134,7 +134,7 @@ pub async fn parent_modify( ctx, ParentDescription { site_id: input.site_id, - parent: parent.clone(), + parent: parent.to_owned(), child: input.child.clone(), }, ) @@ -170,7 +170,7 @@ pub async fn parent_modify( None => None, }; - Ok(ModifyParentOutput { + Ok(UpdateParentsOutput { added: creation, removed: removal, }) diff --git a/deepwell/src/services/page/structs.rs b/deepwell/src/services/page/structs.rs index bb495303541..ab4c165b500 100644 --- a/deepwell/src/services/page/structs.rs +++ b/deepwell/src/services/page/structs.rs @@ -116,7 +116,7 @@ pub struct GetPageOutput { #[derive(Serialize, Debug, Clone)] pub struct GetPageScoreOutput { pub page_id: i64, - pub rating: ScoreValue, + pub score: ScoreValue, } #[derive(Deserialize, Debug, Clone)] diff --git a/deepwell/src/services/parent/structs.rs b/deepwell/src/services/parent/structs.rs index e8cc9eda88a..5f494af7967 100644 --- a/deepwell/src/services/parent/structs.rs +++ b/deepwell/src/services/parent/structs.rs @@ -30,7 +30,7 @@ pub struct ParentDescription<'a> { } #[derive(Deserialize, Debug, Clone)] -pub struct ParentModifyDescription<'a> { +pub struct UpdateParents<'a> { pub site_id: i64, pub child: Reference<'a>, pub add: Option>>, @@ -80,7 +80,7 @@ pub struct RemoveParentOutput { } #[derive(Serialize, Debug, Clone)] -pub struct ModifyParentOutput { +pub struct UpdateParentsOutput { pub added: Option>, pub removed: Option>, } diff --git a/framerail/src/routes/[slug]/[...extra]/+server.ts b/framerail/src/routes/[slug]/[...extra]/+server.ts index 55de96b4eb1..cc01128645b 100644 --- a/framerail/src/routes/[slug]/[...extra]/+server.ts +++ b/framerail/src/routes/[slug]/[...extra]/+server.ts @@ -99,7 +99,7 @@ export async function POST(event) { let layout = data.get("layout")?.toString().trim() ?? null res = await page.pageLayout(siteId, pageId, session?.user_id, layout) - } else if (extra.includes("parentset")) { + } else if (extra.includes("parent-set")) { let oldParentStr = data.get("old-parents")?.toString().trim() ?? "" let oldParent = oldParentStr.split(" ") let newParentStr = data.get("new-parents")?.toString().trim() ?? "" @@ -116,7 +116,7 @@ export async function POST(event) { } res = await page.pageParentModify(siteId, pageId, session?.user_id, added, removed) - } else if (extra.includes("parentget")) { + } else if (extra.includes("parent-get")) { res = await page.pageParentGet(siteId, pageId, slug) } else if (extra.includes("score")) { res = await page.pageScore(siteId, pageId, slug) diff --git a/framerail/src/routes/[slug]/[...extra]/page.svelte b/framerail/src/routes/[slug]/[...extra]/page.svelte index b164db1cc69..f0fba5cc595 100644 --- a/framerail/src/routes/[slug]/[...extra]/page.svelte +++ b/framerail/src/routes/[slug]/[...extra]/page.svelte @@ -130,7 +130,7 @@ let fdata = new FormData() fdata.set("site-id", $page.data.site.site_id) fdata.set("page-id", $page.data.page.page_id) - let res = await fetch(`/${$page.data.page.slug}/parentget`, { + let res = await fetch(`/${$page.data.page.slug}/parent-get`, { method: "POST", body: fdata }).then((res) => res.json()) @@ -151,7 +151,7 @@ fdata.set("site-id", $page.data.site.site_id) fdata.set("page-id", $page.data.page.page_id) fdata.set("old-parents", parents) - let res = await fetch(`/${$page.data.page.slug}/parentset`, { + let res = await fetch(`/${$page.data.page.slug}/parent-set`, { method: "POST", body: fdata }).then((res) => res.json()) @@ -262,7 +262,7 @@ message: res.message }) } else { - voteRating = res.rating ?? 0 + voteRating = res.score ?? 0 showVote = true } }