feat: atomic goal, watchlist, profile writes

This commit is contained in:
2026-10-26 00:49:28 +01:00
parent c8a1e8bfe4
commit 62ad9f4017
48 changed files with 1296 additions and 264 deletions

View File

@@ -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,