Refactor application context and repository structure
- 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.
This commit is contained in:
@@ -17,15 +17,15 @@ pub async fn execute(ctx: &AppContext, cmd: LogReviewCommand) -> Result<(), Doma
|
||||
let comment = cmd.comment.clone().map(Comment::new).transpose()?;
|
||||
|
||||
let deps = MovieResolverDeps {
|
||||
repository: ctx.repository.as_ref(),
|
||||
repository: ctx.movie_repository.as_ref(),
|
||||
metadata_client: ctx.metadata_client.as_ref(),
|
||||
};
|
||||
let (movie, is_new_movie) = MovieResolver::default_pipeline().resolve(&cmd, &deps).await?;
|
||||
|
||||
ctx.repository.upsert_movie(&movie).await?;
|
||||
ctx.movie_repository.upsert_movie(&movie).await?;
|
||||
|
||||
let review = Review::new(movie.id().clone(), user_id, rating, comment, cmd.watched_at)?;
|
||||
let review_event = ctx.repository.save_review(&review).await?;
|
||||
let review_event = ctx.review_repository.save_review(&review).await?;
|
||||
|
||||
publish_events(ctx, &movie, is_new_movie, review_event).await?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user