Skip to content

Commit db6351b

Browse files
committed
pr fixes
1 parent 06f4342 commit db6351b

File tree

2 files changed

+13
-22
lines changed

2 files changed

+13
-22
lines changed

rust/cloud-storage/properties/src/outbound/entity_property_queries.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! General entity property query helpers.
22
3-
use anyhow::Context;
43
use models_properties::EntityType;
54
use models_properties::service::property_value::PropertyValue;
65
use sqlx::{Pool, Postgres};
@@ -17,7 +16,7 @@ pub async fn update_entity_property_value_if_exists(
1716
) -> anyhow::Result<()> {
1817
// Serialize PropertyValue to JSONB (or NULL if None)
1918
let value_json = match value {
20-
Some(v) => serde_json::to_value(&v).context("failed to serialize property value")?,
19+
Some(v) => serde_json::to_value(&v)?,
2120
None => serde_json::Value::Null,
2221
};
2322

@@ -38,11 +37,10 @@ pub async fn update_entity_property_value_if_exists(
3837
value_json
3938
)
4039
.execute(pool)
41-
.await
42-
.context("failed to update entity property")?;
40+
.await?;
4341

4442
if result.rows_affected() > 0 {
45-
tracing::info!("successfully updated entity property");
43+
tracing::debug!("successfully updated entity property");
4644
} else {
4745
tracing::debug!("entity property not attached, no-op");
4846
}

rust/cloud-storage/properties/src/outbound/task_property_queries.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use std::collections::HashSet;
44

5-
use anyhow::Context;
65
use models_properties::EntityReference;
76
use models_properties::EntityType;
87
use models_properties::service::property_value::PropertyValue;
@@ -25,7 +24,7 @@ pub async fn link_parent_task(
2524
anyhow::bail!("a task cannot be its own parent");
2625
}
2726

28-
let mut tx = pool.begin().await.context("failed to begin transaction")?;
27+
let mut tx = pool.begin().await?;
2928

3029
// Validate: can't set a subtask as parent (would create mutual reference)
3130
if let Some(parent_id) = parent_task_id {
@@ -60,7 +59,7 @@ pub async fn link_parent_task(
6059
tracing::debug!("task does not exist, skipping subtasks update");
6160
}
6261

63-
tx.commit().await.context("failed to commit transaction")?;
62+
tx.commit().await?;
6463
tracing::info!("successfully linked parent task");
6564
Ok(())
6665
}
@@ -83,7 +82,7 @@ pub async fn link_subtasks(
8382
.into_iter()
8483
.collect();
8584

86-
let mut tx = pool.begin().await.context("failed to begin transaction")?;
85+
let mut tx = pool.begin().await?;
8786

8887
// Validate: can't include parent as subtask (would create mutual reference)
8988
if let Some(current_parent) = get_task_parent(&mut tx, task_id).await?
@@ -136,7 +135,7 @@ pub async fn link_subtasks(
136135
let _ = set_task_parent(&mut tx, *subtask_id, None).await?;
137136
}
138137

139-
tx.commit().await.context("failed to commit transaction")?;
138+
tx.commit().await?;
140139
tracing::info!(
141140
added_count = added.len(),
142141
removed_count = removed.len(),
@@ -167,8 +166,7 @@ async fn get_task_parent(tx: &mut PgConnection, task_id: Uuid) -> anyhow::Result
167166
parent_task_prop_id
168167
)
169168
.fetch_optional(&mut *tx)
170-
.await
171-
.context("failed to get task's parent")?;
169+
.await?;
172170

173171
Ok(parent_str
174172
.flatten()
@@ -194,8 +192,7 @@ async fn get_task_subtasks(tx: &mut PgConnection, task_id: Uuid) -> anyhow::Resu
194192
subtasks_prop_id
195193
)
196194
.fetch_all(&mut *tx)
197-
.await
198-
.context("failed to get task's subtasks")?;
195+
.await?;
199196

200197
Ok(subtask_strs
201198
.into_iter()
@@ -226,8 +223,7 @@ async fn set_task_parent(
226223
let parent_value = match parent_task_id {
227224
Some(parent_id) => {
228225
let entity_ref = EntityReference::new(parent_id.to_string(), EntityType::Task);
229-
serde_json::to_value(PropertyValue::EntityRef(vec![entity_ref]))
230-
.context("failed to serialize parent task value")?
226+
serde_json::to_value(PropertyValue::EntityRef(vec![entity_ref]))?
231227
}
232228
None => serde_json::Value::Null,
233229
};
@@ -246,8 +242,7 @@ async fn set_task_parent(
246242
parent_value
247243
)
248244
.execute(&mut *tx)
249-
.await
250-
.context("failed to set task's parent")?;
245+
.await?;
251246

252247
Ok(result.rows_affected() > 0)
253248
}
@@ -285,8 +280,7 @@ async fn set_task_subtasks(
285280
.iter()
286281
.map(|id| EntityReference::new(id.to_string(), EntityType::Task))
287282
.collect();
288-
serde_json::to_value(PropertyValue::EntityRef(refs))
289-
.context("failed to serialize subtasks value")?
283+
serde_json::to_value(PropertyValue::EntityRef(refs))?
290284
};
291285

292286
sqlx::query!(
@@ -303,8 +297,7 @@ async fn set_task_subtasks(
303297
subtasks_value
304298
)
305299
.execute(&mut *tx)
306-
.await
307-
.context("failed to set task's subtasks")?;
300+
.await?;
308301

309302
Ok(())
310303
}

0 commit comments

Comments
 (0)