Files
movies-diary/crates/application/src/goals/list.rs
Gabriel Kaszewski 6a9b4e5c00 refactor: LOW+MEDIUM cleanups — CQRS DiaryQuery/GoalCommand+GoalQuery,
test-helpers out of production, decompose get_user_profile_html,
dedup secure_flag, remove vestigial social_query, drop
PersistedImportSession, LoginCommand rename, DeleteAccountDeps,
PersonId macro, ReviewSortBy rename, TUI Command for fs::read,
generic PaginatedResponse<T>, noop ports for production fallbacks
2026-07-10 05:29:02 +02:00

27 lines
725 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_query.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;