- Updated `AppContext` to include separate repositories for movies, reviews, diaries, and stats. - Modified use cases to utilize the new repository structure, ensuring that the correct repositories are called for their respective operations. - Introduced `DiaryRepository` and `StatsRepository` traits to encapsulate diary and statistics-related operations. - Updated all relevant use cases, handlers, and tests to reflect the changes in repository usage. - Ensured that panic repositories are updated to implement the new traits for testing purposes.
24 lines
650 B
Rust
24 lines
650 B
Rust
use domain::{
|
|
errors::DomainError,
|
|
models::ReviewHistory,
|
|
services::review_history::{ReviewHistoryAnalyzer, Trend},
|
|
value_objects::MovieId,
|
|
};
|
|
|
|
use crate::{context::AppContext, queries::GetReviewHistoryQuery};
|
|
|
|
pub async fn execute(
|
|
ctx: &AppContext,
|
|
query: GetReviewHistoryQuery,
|
|
) -> Result<(ReviewHistory, Trend), DomainError> {
|
|
let movie_id = MovieId::from_uuid(query.movie_id);
|
|
|
|
let mut history = ctx.diary_repository.get_review_history(&movie_id).await?;
|
|
|
|
let trend = ReviewHistoryAnalyzer::rating_trend(&history)?;
|
|
|
|
ReviewHistoryAnalyzer::sort_chronologically(&mut history);
|
|
|
|
Ok((history, trend))
|
|
}
|