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:
@@ -1,26 +1,22 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use domain::{
|
||||
errors::DomainError,
|
||||
models::GoalWithProgress,
|
||||
ports::{GoalRepository, StatsRepository},
|
||||
value_objects::UserId,
|
||||
};
|
||||
|
||||
use super::queries::GetGoalQuery;
|
||||
use super::{deps::GoalQueryDeps, queries::GetGoalQuery};
|
||||
|
||||
pub async fn execute(
|
||||
goal: Arc<dyn GoalRepository>,
|
||||
stats: Arc<dyn StatsRepository>,
|
||||
deps: &GoalQueryDeps,
|
||||
query: GetGoalQuery,
|
||||
) -> 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 = deps.goal.find_by_user_and_year(&user_id, query.year).await?;
|
||||
|
||||
let Some(g) = found else { return Ok(None) };
|
||||
|
||||
let current_count = stats.count_reviews_in_year(&user_id, query.year).await?;
|
||||
let current_count = deps.stats.count_reviews_in_year(&user_id, query.year).await?;
|
||||
|
||||
Ok(Some(GoalWithProgress {
|
||||
goal: g,
|
||||
|
||||
Reference in New Issue
Block a user