From 7bcbc595871ccf212b9ee6fdef61e77308d5cc3d Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Tue, 9 Jun 2026 02:12:35 +0200 Subject: [PATCH] fix: implement get_all_reviews_for_user, add crate metadata Replace todo!() stubs in sqlite/postgres adapters with actual queries. Add description+license to presentation crate. --- crates/adapters/postgres/src/lib.rs | 18 ++++++++++++++++-- crates/adapters/sqlite/src/lib.rs | 15 +++++++++++++-- crates/presentation/Cargo.toml | 2 ++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/crates/adapters/postgres/src/lib.rs b/crates/adapters/postgres/src/lib.rs index 712d5d0..75b2011 100644 --- a/crates/adapters/postgres/src/lib.rs +++ b/crates/adapters/postgres/src/lib.rs @@ -586,9 +586,23 @@ impl ReviewRepository for PostgresRepository { async fn get_all_reviews_for_user( &self, - _user_id: &UserId, + user_id: &UserId, ) -> Result, DomainError> { - todo!() + let uid = user_id.value().to_string(); + sqlx::query_as::<_, ReviewRow>( + "SELECT id, movie_id, user_id, rating, comment, + to_char(watched_at AT TIME ZONE 'UTC', 'YYYY-MM-DD HH24:MI:SS') AS watched_at, + to_char(created_at AT TIME ZONE 'UTC', 'YYYY-MM-DD HH24:MI:SS') AS created_at, + remote_actor_url + FROM reviews WHERE user_id = $1 ORDER BY watched_at DESC", + ) + .bind(&uid) + .fetch_all(&self.pool) + .await + .map_err(Self::map_err)? + .into_iter() + .map(ReviewRow::into_domain) + .collect() } } diff --git a/crates/adapters/sqlite/src/lib.rs b/crates/adapters/sqlite/src/lib.rs index df675d7..dfa6ea6 100644 --- a/crates/adapters/sqlite/src/lib.rs +++ b/crates/adapters/sqlite/src/lib.rs @@ -578,9 +578,20 @@ impl ReviewRepository for SqliteMovieRepository { async fn get_all_reviews_for_user( &self, - _user_id: &UserId, + user_id: &UserId, ) -> Result, DomainError> { - todo!() + let uid = user_id.value().to_string(); + sqlx::query_as::<_, ReviewRow>( + "SELECT id, movie_id, user_id, rating, comment, watched_at, created_at, remote_actor_url + FROM reviews WHERE user_id = ? ORDER BY watched_at DESC", + ) + .bind(&uid) + .fetch_all(&self.pool) + .await + .map_err(Self::map_err)? + .into_iter() + .map(ReviewRow::into_domain) + .collect() } } diff --git a/crates/presentation/Cargo.toml b/crates/presentation/Cargo.toml index acc84a4..e5007f8 100644 --- a/crates/presentation/Cargo.toml +++ b/crates/presentation/Cargo.toml @@ -2,6 +2,8 @@ name = "presentation" version = "0.1.0" edition = "2024" +description = "Self-hosted movie diary with REST API and ActivityPub federation" +license = "MIT" [features] default = ["sqlite", "sqlite-federation"]