22
33use std:: collections:: HashSet ;
44
5- use anyhow:: Context ;
65use models_properties:: EntityReference ;
76use models_properties:: EntityType ;
87use 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