mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
[rust]:delete app from trash
This commit is contained in:
@ -101,6 +101,7 @@ pub(crate) async fn update_app(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(transaction), err)]
|
||||
pub(crate) async fn delete_app(transaction: &mut DBTransaction<'_>, app_id: Uuid) -> Result<(), ServerError> {
|
||||
let (sql, args) = SqlBuilder::delete(APP_TABLE).and_where_eq("id", app_id).build()?;
|
||||
let _ = sqlx::query_with(&sql, args)
|
||||
|
@ -59,7 +59,7 @@ pub async fn delete_handler(
|
||||
let _ = delete_all_trash(&mut transaction, &logged_user).await?;
|
||||
} else {
|
||||
let records = make_records(params)?;
|
||||
let _ = delete_trash(&mut transaction, records, &logged_user).await?;
|
||||
let _ = delete_trash(&mut transaction, records).await?;
|
||||
}
|
||||
|
||||
transaction
|
||||
|
@ -13,6 +13,7 @@ use flowy_workspace::protobuf::{RepeatedTrash, Trash, TrashType};
|
||||
use sqlx::{postgres::PgArguments, Postgres, Row};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[tracing::instrument(skip(transaction, user), err)]
|
||||
pub(crate) async fn create_trash(
|
||||
transaction: &mut DBTransaction<'_>,
|
||||
records: Vec<(Uuid, i32)>,
|
||||
@ -66,10 +67,10 @@ pub(crate) async fn delete_all_trash(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(transaction), err)]
|
||||
pub(crate) async fn delete_trash(
|
||||
transaction: &mut DBTransaction<'_>,
|
||||
records: Vec<(Uuid, i32)>,
|
||||
_user: &LoggedUser,
|
||||
) -> Result<(), ServerError> {
|
||||
for (trash_id, _) in records {
|
||||
// Read the trash_table and delete the original table according to the TrashType
|
||||
@ -99,6 +100,7 @@ pub(crate) async fn delete_trash(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(transaction, targets), err)]
|
||||
async fn delete_trash_targets(
|
||||
transaction: &mut DBTransaction<'_>,
|
||||
targets: Vec<(Uuid, i32)>,
|
||||
@ -134,6 +136,7 @@ pub(crate) async fn read_trash_ids(
|
||||
Ok(ids)
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(transaction, user), err)]
|
||||
pub(crate) async fn read_trash(
|
||||
transaction: &mut DBTransaction<'_>,
|
||||
user: &LoggedUser,
|
||||
|
@ -44,6 +44,7 @@ pub(crate) async fn update_view(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(transaction), err)]
|
||||
pub(crate) async fn delete_view(transaction: &mut DBTransaction<'_>, view_ids: Vec<Uuid>) -> Result<(), ServerError> {
|
||||
for view_id in view_ids {
|
||||
let (sql, args) = SqlBuilder::delete(VIEW_TABLE).and_where_eq("id", &view_id).build()?;
|
||||
|
@ -66,6 +66,7 @@ pub(crate) async fn delete_workspace(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(transaction, logged_user), err)]
|
||||
pub async fn read_workspaces(
|
||||
transaction: &mut DBTransaction<'_>,
|
||||
workspace_id: Option<String>,
|
||||
@ -109,7 +110,7 @@ pub async fn read_workspaces(
|
||||
Ok(repeated_workspace)
|
||||
}
|
||||
|
||||
// transaction must be commit from caller
|
||||
#[tracing::instrument(skip(transaction, user), fields(app_count), err)]
|
||||
async fn read_workspace_apps<'c>(
|
||||
user: &LoggedUser,
|
||||
transaction: &mut DBTransaction<'_>,
|
||||
@ -126,6 +127,7 @@ async fn read_workspace_apps<'c>(
|
||||
.await
|
||||
.map_err(map_sqlx_error)?;
|
||||
|
||||
tracing::Span::current().record("app_count", &app_tables.len());
|
||||
let mut apps = vec![];
|
||||
for table in app_tables {
|
||||
let app = read_app(transaction, table.id, user).await?;
|
||||
|
Reference in New Issue
Block a user