Skip to content

Commit

Permalink
Fix: consistency and other minor things
Browse files Browse the repository at this point in the history
  • Loading branch information
Zokhoi committed Sep 24, 2024
1 parent 0650030 commit 5d6ec33
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions deepwell/src/endpoints/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 9 additions & 9 deletions deepwell/src/endpoints/parent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -108,8 +108,8 @@ pub async fn parent_get_all(

let pages: Vec<String> = 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)
Expand All @@ -118,11 +118,11 @@ pub async fn parent_get_all(
pub async fn parent_modify(
ctx: &ServiceContext<'_>,
params: Params<'static>,
) -> Result<ModifyParentOutput> {
let input: ParentModifyDescription = params.parse()?;
) -> Result<UpdateParentsOutput> {
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,
);

Expand All @@ -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(),
},
)
Expand Down Expand Up @@ -170,7 +170,7 @@ pub async fn parent_modify(
None => None,
};

Ok(ModifyParentOutput {
Ok(UpdateParentsOutput {
added: creation,
removed: removal,
})
Expand Down
2 changes: 1 addition & 1 deletion deepwell/src/services/page/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions deepwell/src/services/parent/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<Reference<'a>>>,
Expand Down Expand Up @@ -80,7 +80,7 @@ pub struct RemoveParentOutput {
}

#[derive(Serialize, Debug, Clone)]
pub struct ModifyParentOutput {
pub struct UpdateParentsOutput {
pub added: Option<Vec<i64>>,
pub removed: Option<Vec<bool>>,
}
4 changes: 2 additions & 2 deletions framerail/src/routes/[slug]/[...extra]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() ?? ""
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions framerail/src/routes/[slug]/[...extra]/page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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())
Expand Down Expand Up @@ -262,7 +262,7 @@
message: res.message
})
} else {
voteRating = res.rating ?? 0
voteRating = res.score ?? 0
showVote = true
}
}
Expand Down

0 comments on commit 5d6ec33

Please sign in to comment.