fix: honest review update rollback test, goal delete NotFound fake, read before write
This commit is contained in:
@@ -29,6 +29,8 @@ pub async fn execute(
|
||||
cmd.target_count,
|
||||
GoalType::Movies,
|
||||
)?;
|
||||
// Reads that can fail happen before the write, so an error never follows a commit.
|
||||
let current_count = deps.stats.count_reviews_in_year(&user_id, cmd.year).await?;
|
||||
let event = DomainEvent::GoalCreated {
|
||||
goal_id: g.id().clone(),
|
||||
user_id: user_id.clone(),
|
||||
@@ -37,8 +39,6 @@ pub async fn execute(
|
||||
};
|
||||
deps.goal_command.save(&g, &[event]).await?;
|
||||
|
||||
let current_count = deps.stats.count_reviews_in_year(&user_id, cmd.year).await?;
|
||||
|
||||
Ok(GoalWithProgress {
|
||||
goal: g,
|
||||
current_count,
|
||||
|
||||
@@ -17,6 +17,8 @@ pub async fn execute(
|
||||
.ok_or_else(|| DomainError::NotFound(format!("Goal for year {}", cmd.year)))?;
|
||||
|
||||
g.update_target(cmd.target_count)?;
|
||||
// Reads that can fail happen before the write, so an error never follows a commit.
|
||||
let current_count = deps.stats.count_reviews_in_year(&user_id, cmd.year).await?;
|
||||
let event = DomainEvent::GoalUpdated {
|
||||
goal_id: g.id().clone(),
|
||||
user_id: user_id.clone(),
|
||||
@@ -25,8 +27,6 @@ pub async fn execute(
|
||||
};
|
||||
deps.goal_command.update(&g, &[event]).await?;
|
||||
|
||||
let current_count = deps.stats.count_reviews_in_year(&user_id, cmd.year).await?;
|
||||
|
||||
Ok(GoalWithProgress {
|
||||
goal: g,
|
||||
current_count,
|
||||
|
||||
Reference in New Issue
Block a user