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:
2026-05-09 18:58:29 +02:00
parent 29a5972c01
commit 89e78a0d1f
19 changed files with 260 additions and 311 deletions

View File

@@ -96,9 +96,13 @@ async fn test_app() -> Router {
let repo = SqliteMovieRepository::new(pool);
repo.migrate().await.expect("migration failed");
let repo = Arc::new(repo);
let state = AppState {
app_ctx: AppContext {
repository: Arc::new(repo),
movie_repository: Arc::clone(&repo) as _,
review_repository: Arc::clone(&repo) as _,
diary_repository: Arc::clone(&repo) as _,
stats_repository: Arc::clone(&repo) as _,
metadata_client: Arc::new(PanicMeta),
poster_fetcher: Arc::new(PanicFetcher),
poster_storage: Arc::new(PanicStorage),