refactor: remaining MEDIUM — CQRS splits, DI Deps, profile dedup, event Value, response enum
M1: MovieRepository→MovieCommand/MovieQuery, WatchEventRepository→ WatchEventCommand/WatchEventQuery M2: goals/ and import/ use Deps structs M7: extract upload_image helper in update_profile M8: FederationDeliveryRequested activity_json String→serde_json::Value M11: UserProfileResponse uses ProfileViewData enum
This commit is contained in:
@@ -3,15 +3,16 @@ use std::sync::Arc;
|
||||
use anyhow::Context;
|
||||
use domain::ports::{
|
||||
DiaryRepository, GoalRepository, ImageRefCommand, ImageRefQuery, ImportSessionRepository,
|
||||
LocalApContentQuery, MovieDeduplicator, MovieProfileRepository, MovieRepository, PersonCommand,
|
||||
PersonQuery, ReviewRepository, SearchCommand, StatsRepository, UserRepository,
|
||||
WatchEventRepository,
|
||||
LocalApContentQuery, MovieCommand, MovieDeduplicator, MovieProfileRepository, MovieQuery,
|
||||
PersonCommand, PersonQuery, ReviewRepository, SearchCommand, StatsRepository, UserRepository,
|
||||
WatchEventCommand, WatchEventQuery,
|
||||
};
|
||||
|
||||
pub use infra_wiring::DbPool;
|
||||
|
||||
pub struct WorkerDbOutput {
|
||||
pub movie: Arc<dyn MovieRepository>,
|
||||
pub movie_command: Arc<dyn MovieCommand>,
|
||||
pub movie_query: Arc<dyn MovieQuery>,
|
||||
pub review: Arc<dyn ReviewRepository>,
|
||||
pub diary: Arc<dyn DiaryRepository>,
|
||||
pub stats: Arc<dyn StatsRepository>,
|
||||
@@ -19,7 +20,8 @@ pub struct WorkerDbOutput {
|
||||
pub user: Arc<dyn UserRepository>,
|
||||
pub import_session: Arc<dyn ImportSessionRepository>,
|
||||
pub movie_profile: Arc<dyn MovieProfileRepository>,
|
||||
pub watch_event: Arc<dyn WatchEventRepository>,
|
||||
pub watch_event_command: Arc<dyn WatchEventCommand>,
|
||||
pub watch_event_query: Arc<dyn WatchEventQuery>,
|
||||
pub person_command: Arc<dyn PersonCommand>,
|
||||
pub person_query: Arc<dyn PersonQuery>,
|
||||
pub search_command: Arc<dyn SearchCommand>,
|
||||
@@ -46,10 +48,10 @@ pub async fn connect(database_url: &str, backend: &str) -> anyhow::Result<Worker
|
||||
let (person_command, person_query) = postgres::create_person_adapter(w.pool.clone());
|
||||
let (search_command, _search_port) =
|
||||
postgres_search::create_search_adapter(w.pool.clone());
|
||||
let we: Arc<dyn WatchEventRepository> =
|
||||
Arc::new(postgres::PostgresWatchEventRepository::new(w.pool.clone()));
|
||||
let we = Arc::new(postgres::PostgresWatchEventRepository::new(w.pool.clone()));
|
||||
Ok(WorkerDbOutput {
|
||||
movie: w.movie,
|
||||
movie_command: w.movie_command,
|
||||
movie_query: w.movie_query,
|
||||
review: w.review,
|
||||
diary: w.diary,
|
||||
stats: w.stats,
|
||||
@@ -57,7 +59,8 @@ pub async fn connect(database_url: &str, backend: &str) -> anyhow::Result<Worker
|
||||
user: w.user,
|
||||
import_session: w.import_session,
|
||||
movie_profile: w.movie_profile,
|
||||
watch_event: we,
|
||||
watch_event_command: we.clone() as _,
|
||||
watch_event_query: we as _,
|
||||
person_command,
|
||||
person_query,
|
||||
search_command,
|
||||
@@ -84,10 +87,10 @@ pub async fn connect(database_url: &str, backend: &str) -> anyhow::Result<Worker
|
||||
let (person_command, person_query) = sqlite::create_person_adapter(w.pool.clone());
|
||||
let (search_command, _search_port) =
|
||||
sqlite_search::create_search_adapter(w.pool.clone());
|
||||
let we: Arc<dyn WatchEventRepository> =
|
||||
Arc::new(sqlite::SqliteWatchEventRepository::new(w.pool.clone()));
|
||||
let we = Arc::new(sqlite::SqliteWatchEventRepository::new(w.pool.clone()));
|
||||
Ok(WorkerDbOutput {
|
||||
movie: w.movie,
|
||||
movie_command: w.movie_command,
|
||||
movie_query: w.movie_query,
|
||||
review: w.review,
|
||||
diary: w.diary,
|
||||
stats: w.stats,
|
||||
@@ -95,7 +98,8 @@ pub async fn connect(database_url: &str, backend: &str) -> anyhow::Result<Worker
|
||||
user: w.user,
|
||||
import_session: w.import_session,
|
||||
movie_profile: w.movie_profile,
|
||||
watch_event: we,
|
||||
watch_event_command: we.clone() as _,
|
||||
watch_event_query: we as _,
|
||||
person_command,
|
||||
person_query,
|
||||
search_command,
|
||||
|
||||
@@ -50,7 +50,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
allow_registration,
|
||||
) = (
|
||||
Arc::clone(&db.ap_content),
|
||||
Arc::clone(&db.movie),
|
||||
Arc::clone(&db.movie_query),
|
||||
Arc::clone(&db.review),
|
||||
Arc::clone(&db.diary),
|
||||
Arc::clone(&db.goal),
|
||||
@@ -76,12 +76,14 @@ async fn main() -> anyhow::Result<()> {
|
||||
db::DbPool::Postgres(pool) => postgres_federation::wire(pool.clone()),
|
||||
};
|
||||
|
||||
let movie = db.movie;
|
||||
let movie_command = db.movie_command;
|
||||
let movie_query = db.movie_query;
|
||||
let deduplicator = db.deduplicator;
|
||||
let user = db.user;
|
||||
let import_session = db.import_session;
|
||||
let movie_profile = db.movie_profile;
|
||||
let watch_event = db.watch_event;
|
||||
let watch_event_command = db.watch_event_command;
|
||||
let watch_event_query = db.watch_event_query;
|
||||
let person_command = db.person_command;
|
||||
let person_query = db.person_query;
|
||||
let search_command = db.search_command;
|
||||
@@ -111,7 +113,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
let image_fetcher = poster_fetcher::create_image_fetcher()?;
|
||||
let handler = Arc::new(application::movies::MovieEnrichmentHandler::new(
|
||||
Arc::clone(&client) as Arc<dyn MovieEnrichmentClient>,
|
||||
Arc::clone(&movie),
|
||||
Arc::clone(&movie_query),
|
||||
Arc::clone(&movie_profile),
|
||||
Arc::clone(&person_command),
|
||||
Arc::clone(&search_command),
|
||||
@@ -149,7 +151,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
|
||||
let mut periodic_jobs: Vec<Arc<dyn PeriodicJob>> = vec![
|
||||
Arc::new(application::jobs::MovieDeduplicationJob::new(
|
||||
Arc::clone(&movie),
|
||||
Arc::clone(&movie_query),
|
||||
Arc::clone(&deduplicator),
|
||||
Arc::clone(&object_storage),
|
||||
)),
|
||||
@@ -157,7 +159,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
import_session.clone(),
|
||||
)),
|
||||
Arc::new(application::jobs::WatchEventCleanupJob::new(
|
||||
watch_event.clone(),
|
||||
watch_event_command.clone(),
|
||||
)),
|
||||
Arc::new(application::jobs::WrapUpAutoGenerateJob::new(
|
||||
Arc::clone(&user),
|
||||
@@ -194,7 +196,8 @@ async fn main() -> anyhow::Result<()> {
|
||||
|
||||
let handlers: Vec<Arc<dyn EventHandler>> = {
|
||||
let poster = Arc::new(poster_sync::PosterSyncHandler::new(
|
||||
Arc::clone(&movie),
|
||||
Arc::clone(&movie_command),
|
||||
Arc::clone(&movie_query),
|
||||
Arc::clone(&metadata),
|
||||
Arc::clone(&poster_fetcher),
|
||||
Arc::clone(&object_storage),
|
||||
@@ -212,7 +215,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
)) as Arc<dyn EventHandler>;
|
||||
|
||||
let discovery_indexer = Arc::new(MovieDiscoveryIndexer::new(
|
||||
Arc::clone(&movie),
|
||||
Arc::clone(&movie_query),
|
||||
Arc::clone(&search_command),
|
||||
)) as Arc<dyn EventHandler>;
|
||||
|
||||
@@ -223,7 +226,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
)) as Arc<dyn EventHandler>;
|
||||
|
||||
let reindex_handler = Arc::new(SearchReindexHandler::new(ReindexSearchDeps {
|
||||
movie: Arc::clone(&movie),
|
||||
movie_query: Arc::clone(&movie_query),
|
||||
movie_profile: Arc::clone(&movie_profile),
|
||||
search_command: Arc::clone(&search_command),
|
||||
person_command: Arc::clone(&person_command),
|
||||
|
||||
Reference in New Issue
Block a user