refactor: remaining MEDIUM — CQRS splits, DI Deps, profile dedup, event Value, response enum

M1: MovieRepository→MovieCommand/MovieQuery, WatchEventRepository→
WatchEventCommand/WatchEventQuery
M2: goals/ and import/ use Deps structs
M7: extract upload_image helper in update_profile
M8: FederationDeliveryRequested activity_json String→serde_json::Value
M11: UserProfileResponse uses ProfileViewData enum
This commit is contained in:
2026-07-10 03:50:43 +02:00
parent 12da356a40
commit dee013c7eb
99 changed files with 1262 additions and 896 deletions

View File

@@ -1,34 +1,30 @@
use std::sync::Arc;
use domain::{
errors::DomainError,
events::DomainEvent,
models::GoalWithProgress,
ports::{EventPublisher, GoalRepository, StatsRepository},
value_objects::UserId,
};
use super::commands::UpdateGoalCommand;
use super::{commands::UpdateGoalCommand, deps::GoalCommandDeps};
pub async fn execute(
goal: Arc<dyn GoalRepository>,
stats: Arc<dyn StatsRepository>,
event_publisher: Arc<dyn EventPublisher>,
deps: &GoalCommandDeps,
cmd: UpdateGoalCommand,
) -> Result<GoalWithProgress, DomainError> {
let user_id = UserId::from_uuid(cmd.user_id);
let mut g = goal
let mut g = deps
.goal
.find_by_user_and_year(&user_id, cmd.year)
.await?
.ok_or_else(|| DomainError::NotFound(format!("Goal for year {}", cmd.year)))?;
g.update_target(cmd.target_count)?;
goal.update(&g).await?;
deps.goal.update(&g).await?;
let current_count = stats.count_reviews_in_year(&user_id, cmd.year).await?;
let current_count = deps.stats.count_reviews_in_year(&user_id, cmd.year).await?;
event_publisher
deps.event_publisher
.publish(&DomainEvent::GoalUpdated {
goal_id: g.id().clone(),
user_id,