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
31 lines
734 B
Rust
31 lines
734 B
Rust
use domain::{
|
|
errors::DomainError,
|
|
models::GoalWithProgress,
|
|
value_objects::UserId,
|
|
};
|
|
|
|
use super::{deps::GoalQueryDeps, queries::ListGoalsQuery};
|
|
|
|
pub async fn execute(
|
|
deps: &GoalQueryDeps,
|
|
query: ListGoalsQuery,
|
|
) -> Result<Vec<GoalWithProgress>, DomainError> {
|
|
let user_id = UserId::from_uuid(query.user_id);
|
|
let goals = deps.goal.list_for_user(&user_id).await?;
|
|
|
|
let mut result = Vec::with_capacity(goals.len());
|
|
for g in goals {
|
|
let current_count = deps.stats.count_reviews_in_year(&user_id, g.year()).await?;
|
|
result.push(GoalWithProgress {
|
|
goal: g,
|
|
current_count,
|
|
});
|
|
}
|
|
|
|
Ok(result)
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "tests/list.rs"]
|
|
mod tests;
|