Skip to content

Commit ebe46ba

Browse files
authored
add [properties-be] - link parent and subtasks (#610)
1 parent c2ffb86 commit ebe46ba

23 files changed

+1685
-30
lines changed

rust/cloud-storage/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cloud-storage/document_storage_service/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ models_bulk_upload = { path = "../models_bulk_upload" }
7777
models_opensearch = { path = "../models_opensearch" }
7878
models_pagination = { path = "../models_pagination", features = ["axum"] }
7979
models_permissions = { path = "../models_permissions" }
80+
properties = { path = "../properties" }
8081
models_soup = { path = "../models_soup", features = ["schema"] }
8182
rayon = "1.10.0"
8283
redis = { workspace = true, features = [

rust/cloud-storage/document_storage_service/src/api/context.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use frecency::{domain::services::FrecencyQueryServiceImpl, outbound::postgres::F
88
use macro_auth::middleware::decode_jwt::JwtValidationArgs;
99
use macro_env_var::env_var;
1010
use macro_redis_cluster_client::Redis;
11+
use properties::{PropertiesPgRepo, PropertiesServiceImpl};
1112
use soup::{
1213
domain::service::SoupImpl, inbound::axum_router::SoupRouterState,
1314
outbound::pg_soup_repo::PgSoupRepo,
@@ -32,6 +33,7 @@ type DssSoupState = SoupRouterState<
3233
>;
3334

3435
type SystemPropertiesService = SystemPropertiesServiceImpl<PgSystemPropertiesRepository>;
36+
type PropertiesService = PropertiesServiceImpl<PropertiesPgRepo>;
3537

3638
#[derive(Clone, FromRef)]
3739
pub(crate) struct ApiContext {
@@ -48,6 +50,7 @@ pub(crate) struct ApiContext {
4850
pub conn_gateway_client: Arc<ConnectionGatewayClient>,
4951
pub sync_service_client: Arc<SyncServiceClient>,
5052
pub system_properties_service: Arc<SystemPropertiesService>,
53+
pub properties_service: Arc<PropertiesService>,
5154
pub jwt_validation_args: JwtValidationArgs,
5255
pub config: Arc<Config>,
5356
pub dss_auth_key: DocumentStorageServiceAuthKey,

rust/cloud-storage/document_storage_service/src/api/documents/delete_document.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ use model::response::{
1313
};
1414
use model::user::UserContext;
1515
use models_permissions::share_permission::access_level::OwnerAccessLevel;
16+
use properties::PropertiesService;
1617
use serde::Deserialize;
1718
use sqs_client::search::{SearchQueueMessage, document::DocumentId};
19+
use uuid::Uuid;
1820

1921
#[derive(Deserialize)]
2022
pub struct Params {
@@ -46,6 +48,7 @@ pub async fn delete_document_handler(
4648
doc: Extension<DocumentBasic>,
4749
) -> impl IntoResponse {
4850
tracing::info!("delete document");
51+
4952
// soft delete the document, this will remove the history and pins and mark the document as deleted
5053
if let Err(e) = macro_db_client::document::soft_delete_document(&state.db, &document_id).await {
5154
tracing::error!(error=?e, document_id=?document_id, "unable to soft delete document");
@@ -55,6 +58,24 @@ pub async fn delete_document_handler(
5558
.send(StatusCode::INTERNAL_SERVER_ERROR);
5659
}
5760

61+
// Unlink task parent/subtasks if this is a task (no-op for non-tasks)
62+
if let Ok(task_id) = Uuid::parse_str(&document_id) {
63+
if let Err(e) = state
64+
.properties_service
65+
.link_parent_task(task_id, None)
66+
.await
67+
{
68+
tracing::warn!(error = ?e, "failed to unlink parent task on delete");
69+
}
70+
if let Err(e) = state
71+
.properties_service
72+
.link_subtasks(task_id, vec![])
73+
.await
74+
{
75+
tracing::warn!(error = ?e, "failed to unlink subtasks on delete");
76+
}
77+
}
78+
5879
let response_data = GenericSuccessResponse { success: true };
5980

6081
macro_project_utils::update_project_modified(

rust/cloud-storage/document_storage_service/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use macro_entrypoint::MacroEntrypoint;
1616
use macro_env_var::env_var;
1717
use macro_middleware::auth::internal_access::InternalApiSecretKey;
1818
use macro_redis_cluster_client::Redis;
19+
use properties::{PropertiesPgRepo, PropertiesServiceImpl};
1920
use secretsmanager_client::SecretManager;
2021
use soup::{
2122
domain::service::SoupImpl, inbound::axum_router::SoupRouterState,
@@ -187,6 +188,7 @@ async fn main() -> anyhow::Result<()> {
187188
EmailServiceImpl::new(EmailPgRepo::new(db.clone()), frecency_service.clone());
188189
let system_properties_service =
189190
SystemPropertiesServiceImpl::new(PgSystemPropertiesRepository::new(db.clone()));
191+
let properties_service = PropertiesServiceImpl::new(PropertiesPgRepo::new(db.clone()));
190192
let api_context = ApiContext {
191193
soup_router_state: SoupRouterState::new(
192194
SoupImpl::new(
@@ -213,6 +215,7 @@ async fn main() -> anyhow::Result<()> {
213215
conn_gateway_client: Arc::new(conn_gateway_client),
214216
sync_service_client: Arc::new(sync_service_client),
215217
system_properties_service: Arc::new(system_properties_service),
218+
properties_service: Arc::new(properties_service),
216219
config: Arc::new(config),
217220
jwt_validation_args,
218221
dss_auth_key,

rust/cloud-storage/properties/.sqlx/query-1435acbba365796ddcb6ddbef86f4ebf664cffc44082996f6b60a60373c28f75.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cloud-storage/properties/.sqlx/query-4123b0f2a6fa02a9191a87f2484cb27fd4220b15126fd010acbf4b954a9afb68.json

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cloud-storage/properties/.sqlx/query-63492b018803ce26db5891964a0f52f37d2f54bd8243265c6561f4423af8617c.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cloud-storage/properties/.sqlx/query-805150c1a22fe4cee95588606be11c6419a2e25f66201dfefc8a87a586150d26.json

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cloud-storage/properties/.sqlx/query-9cd40fbb1ade51e9e0d49792839d1a363cada017252a6f653c2272608189bcc4.json

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)