From dda7c40f7f24b05f703cfaf23c751c2c40796a72 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Mon, 4 May 2026 18:53:26 +0200 Subject: [PATCH] fix: validate view param, document V1 history load --- crates/application/src/use_cases/get_user_profile.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/application/src/use_cases/get_user_profile.rs b/crates/application/src/use_cases/get_user_profile.rs index 9ad587d..02436ef 100644 --- a/crates/application/src/use_cases/get_user_profile.rs +++ b/crates/application/src/use_cases/get_user_profile.rs @@ -24,6 +24,8 @@ pub async fn execute( match query.view.as_str() { "history" => { + // V1: loads all entries into memory. Personal diaries are bounded in size; + // spec calls for showing every movie grouped by month, so full load is intentional. let all_entries = ctx.repository.get_user_history(&user_id).await?; let history = group_by_month(all_entries); Ok(UserProfileData { stats, entries: None, history: Some(history), trends: None }) @@ -43,8 +45,7 @@ pub async fn execute( let entries = ctx.repository.query_diary(&filter).await?; Ok(UserProfileData { stats, entries: Some(entries), history: None, trends: None }) } - _ => { - // "recent" (default) + "recent" => { let page = PageParams::new(query.limit, query.offset)?; let filter = DiaryFilter { sort_by: SortDirection::Descending, @@ -55,6 +56,7 @@ pub async fn execute( let entries = ctx.repository.query_diary(&filter).await?; Ok(UserProfileData { stats, entries: Some(entries), history: None, trends: None }) } + other => Err(DomainError::ValidationError(format!("unknown view: {}", other))), } }