refactor: move AppContext to presentation crate, structurally enforce boundary
All checks were successful
CI / Check / Test (push) Successful in 39m33s
All checks were successful
CI / Check / Test (push) Successful in 39m33s
This commit is contained in:
@@ -17,9 +17,7 @@ pub async fn execute(
|
||||
) -> Result<GoalWithProgress, DomainError> {
|
||||
let user_id = UserId::from_uuid(cmd.user_id);
|
||||
|
||||
let existing = goal
|
||||
.find_by_user_and_year(&user_id, cmd.year)
|
||||
.await?;
|
||||
let existing = goal.find_by_user_and_year(&user_id, cmd.year).await?;
|
||||
if existing.is_some() {
|
||||
return Err(DomainError::ValidationError(
|
||||
"Goal already exists for this year".into(),
|
||||
@@ -34,9 +32,7 @@ pub async fn execute(
|
||||
)?;
|
||||
goal.save(&g).await?;
|
||||
|
||||
let current_count = goal
|
||||
.count_reviews_in_year(&user_id, cmd.year)
|
||||
.await?;
|
||||
let current_count = goal.count_reviews_in_year(&user_id, cmd.year).await?;
|
||||
|
||||
event_publisher
|
||||
.publish(&DomainEvent::GoalCreated {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use domain::{errors::DomainError, models::GoalWithProgress, ports::GoalRepository, value_objects::UserId};
|
||||
use domain::{
|
||||
errors::DomainError, models::GoalWithProgress, ports::GoalRepository, value_objects::UserId,
|
||||
};
|
||||
|
||||
use super::queries::GetGoalQuery;
|
||||
|
||||
@@ -10,15 +12,11 @@ pub async fn execute(
|
||||
) -> Result<Option<GoalWithProgress>, DomainError> {
|
||||
let user_id = UserId::from_uuid(query.user_id);
|
||||
|
||||
let found = goal
|
||||
.find_by_user_and_year(&user_id, query.year)
|
||||
.await?;
|
||||
let found = goal.find_by_user_and_year(&user_id, query.year).await?;
|
||||
|
||||
let Some(g) = found else { return Ok(None) };
|
||||
|
||||
let current_count = goal
|
||||
.count_reviews_in_year(&user_id, query.year)
|
||||
.await?;
|
||||
let current_count = goal.count_reviews_in_year(&user_id, query.year).await?;
|
||||
|
||||
Ok(Some(GoalWithProgress {
|
||||
goal: g,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use domain::{errors::DomainError, models::GoalWithProgress, ports::GoalRepository, value_objects::UserId};
|
||||
use domain::{
|
||||
errors::DomainError, models::GoalWithProgress, ports::GoalRepository, value_objects::UserId,
|
||||
};
|
||||
|
||||
use super::queries::ListGoalsQuery;
|
||||
|
||||
@@ -13,9 +15,7 @@ pub async fn execute(
|
||||
|
||||
let mut result = Vec::with_capacity(goals.len());
|
||||
for g in goals {
|
||||
let current_count = goal
|
||||
.count_reviews_in_year(&user_id, g.year())
|
||||
.await?;
|
||||
let current_count = goal.count_reviews_in_year(&user_id, g.year()).await?;
|
||||
result.push(GoalWithProgress {
|
||||
goal: g,
|
||||
current_count,
|
||||
|
||||
@@ -25,9 +25,7 @@ pub async fn execute(
|
||||
g.update_target(cmd.target_count)?;
|
||||
goal.update(&g).await?;
|
||||
|
||||
let current_count = goal
|
||||
.count_reviews_in_year(&user_id, cmd.year)
|
||||
.await?;
|
||||
let current_count = goal.count_reviews_in_year(&user_id, cmd.year).await?;
|
||||
|
||||
event_publisher
|
||||
.publish(&DomainEvent::GoalUpdated {
|
||||
|
||||
Reference in New Issue
Block a user