feat: atomic goal, watchlist, profile writes
This commit is contained in:
@@ -17,19 +17,16 @@ pub async fn execute(
|
||||
.ok_or_else(|| DomainError::NotFound(format!("Goal for year {}", cmd.year)))?;
|
||||
|
||||
g.update_target(cmd.target_count)?;
|
||||
deps.goal_command.update(&g).await?;
|
||||
let event = DomainEvent::GoalUpdated {
|
||||
goal_id: g.id().clone(),
|
||||
user_id: user_id.clone(),
|
||||
year: cmd.year,
|
||||
target_count: cmd.target_count,
|
||||
};
|
||||
deps.goal_command.update(&g, &[event]).await?;
|
||||
|
||||
let current_count = deps.stats.count_reviews_in_year(&user_id, cmd.year).await?;
|
||||
|
||||
deps.event_publisher
|
||||
.publish(&DomainEvent::GoalUpdated {
|
||||
goal_id: g.id().clone(),
|
||||
user_id,
|
||||
year: cmd.year,
|
||||
target_count: cmd.target_count,
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(GoalWithProgress {
|
||||
goal: g,
|
||||
current_count,
|
||||
|
||||
Reference in New Issue
Block a user