Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zokhoi committed Sep 30, 2024
1 parent b53185b commit 800f474
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion deepwell/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ async fn build_module(app_state: ServerState) -> anyhow::Result<RpcModule<Server
register!("page_create", page_create);
register!("page_get", page_get);
register!("page_get_direct", page_get_direct);
register!("page_get_deleted_slug", page_get_deleted_slug);
register!("page_get_deleted", page_get_deleted);
register!("page_get_score", page_get_score);
register!("page_edit", page_edit);
register!("page_delete", page_delete);
Expand Down
14 changes: 7 additions & 7 deletions deepwell/src/endpoints/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::prelude::*;
use crate::models::page::Model as PageModel;
use crate::services::page::{
CreatePage, CreatePageOutput, DeletePage, DeletePageOutput, EditPage, EditPageOutput,
GetPageAnyDetails, GetPageDeletedOutput, GetPageDirect, GetPageOutput,
GetDeletedPageOutput, GetPageAnyDetails, GetPageDirect, GetPageOutput,
GetPageReference, GetPageReferenceDetails, GetPageScoreOutput, GetPageSlug, MovePage,
MovePageOutput, RestorePage, RestorePageOutput, RollbackPage, SetPageLayout,
};
Expand Down Expand Up @@ -74,14 +74,14 @@ pub async fn page_get_direct(
}
}

pub async fn page_get_deleted_slug(
pub async fn page_get_deleted(
ctx: &ServiceContext<'_>,
params: Params<'static>,
) -> Result<Vec<GetPageDeletedOutput>> {
) -> Result<Vec<GetDeletedPageOutput>> {
let GetPageSlug { site_id, slug } = params.parse()?;

info!("Getting deleted page {slug} in site ID {site_id}");
let get_deleted_page = PageService::get_deleted_slug(ctx, site_id, slug)
let get_deleted_page = PageService::get_deleted_by_slug(ctx, site_id, &slug)
.await?
.into_iter()
.map(|page| build_page_deleted_output(ctx, page));
Expand Down Expand Up @@ -261,7 +261,7 @@ async fn build_page_output(
async fn build_page_deleted_output(
ctx: &ServiceContext<'_>,
page: PageModel,
) -> Result<Option<GetPageDeletedOutput>> {
) -> Result<Option<GetDeletedPageOutput>> {
// Get page revision
let revision =
PageRevisionService::get_latest(ctx, page.site_id, page.page_id).await?;
Expand All @@ -270,11 +270,11 @@ async fn build_page_deleted_output(
let rating = ScoreService::score(ctx, page.page_id).await?;

// Build result struct
Ok(Some(GetPageDeletedOutput {
Ok(Some(GetDeletedPageOutput {
page_id: page.page_id,
page_created_at: page.created_at,
page_updated_at: page.updated_at,
page_deleted_at: page.deleted_at,
page_deleted_at: page.deleted_at.expect("Page should be deleted"),
page_revision_count: revision.revision_number,
site_id: page.site_id,
discussion_thread_id: page.discussion_thread_id,
Expand Down
7 changes: 4 additions & 3 deletions deepwell/src/services/page/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,20 +566,21 @@ impl PageService {
}

/// Gets all deleted pages that match the provided slug.
pub async fn get_deleted_slug(
pub async fn get_deleted_by_slug(
ctx: &ServiceContext<'_>,
site_id: i64,
slug: String,
slug: &str,
) -> Result<Vec<PageModel>> {
let txn = ctx.transaction();
let pages = {
Page::find()
.filter(
Condition::all()
.add(page::Column::Slug.eq(trim_default(&slug)))
.add(page::Column::Slug.eq(trim_default(slug)))
.add(page::Column::SiteId.eq(site_id))
.add(page::Column::DeletedAt.is_not_null()),
)
.order_by_desc(page::Column::CreatedAt)
.all(txn)
.await?
};
Expand Down
4 changes: 2 additions & 2 deletions deepwell/src/services/page/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ pub struct GetPageOutput {
}

#[derive(Serialize, Debug, Clone)]
pub struct GetPageDeletedOutput {
pub struct GetDeletedPageOutput {
pub page_id: i64,
pub page_created_at: OffsetDateTime,
pub page_updated_at: Option<OffsetDateTime>,
pub page_deleted_at: Option<OffsetDateTime>,
pub page_deleted_at: OffsetDateTime,
pub page_revision_count: i32,
pub site_id: i64,
pub discussion_thread_id: Option<i64>,
Expand Down
2 changes: 1 addition & 1 deletion framerail/src/lib/server/deepwell/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export async function pageParentGet(
}

export async function pageDeletedGet(siteId: number, slug: string): Promise<object> {
return client.request("page_get_deleted_slug", {
return client.request("page_get_deleted", {
site_id: siteId,
slug
})
Expand Down

0 comments on commit 800f474

Please sign in to comment.