This commit is contained in:
2026-06-11 14:03:05 +02:00
parent 2074a2244e
commit b09ef4686a
3 changed files with 14 additions and 14 deletions

View File

@@ -1,9 +1,5 @@
use async_trait::async_trait; use async_trait::async_trait;
use domain::{ use domain::{errors::DomainError, events::DomainEvent, ports::EventHandler};
errors::DomainError,
events::DomainEvent,
ports::EventHandler,
};
use application::context::AppContext; use application::context::AppContext;

View File

@@ -1,13 +1,14 @@
use crate::context::AppContext; use crate::context::AppContext;
use chrono::Utc; use chrono::Utc;
use domain::{ use domain::{errors::DomainError, models::PersonId};
errors::DomainError,
models::PersonId,
};
const STALENESS_DAYS: i64 = 90; const STALENESS_DAYS: i64 = 90;
pub async fn execute(ctx: &AppContext, person_id: PersonId, external_id: &str) -> Result<(), DomainError> { pub async fn execute(
ctx: &AppContext,
person_id: PersonId,
external_id: &str,
) -> Result<(), DomainError> {
if let Some(person) = ctx.repos.person_query.get_by_id(&person_id).await? if let Some(person) = ctx.repos.person_query.get_by_id(&person_id).await?
&& let Some(at) = person.enriched_at() && let Some(at) = person.enriched_at()
&& (Utc::now() - at).num_days() < STALENESS_DAYS && (Utc::now() - at).num_days() < STALENESS_DAYS
@@ -29,7 +30,10 @@ pub async fn execute(ctx: &AppContext, person_id: PersonId, external_id: &str) -
Err(e) => return Err(e), Err(e) => return Err(e),
}; };
ctx.repos.person_command.update_enrichment(&person_id, &data).await?; ctx.repos
.person_command
.update_enrichment(&person_id, &data)
.await?;
tracing::info!(person_id = %person_id.value(), "person enriched"); tracing::info!(person_id = %person_id.value(), "person enriched");
Ok(()) Ok(())
} }

View File

@@ -148,9 +148,9 @@ async fn main() -> anyhow::Result<()> {
)) as Arc<dyn EventHandler>; )) as Arc<dyn EventHandler>;
ctx.services.person_enrichment = ctx.services.person_enrichment =
Some(Arc::clone(&client) as Arc<dyn PersonEnrichmentClient>); Some(Arc::clone(&client) as Arc<dyn PersonEnrichmentClient>);
let person_handler = Arc::new(tmdb_enrichment::PersonEnrichmentHandler::new( let person_handler =
ctx.clone(), Arc::new(tmdb_enrichment::PersonEnrichmentHandler::new(ctx.clone()))
)) as Arc<dyn EventHandler>; as Arc<dyn EventHandler>;
let job = Arc::new(application::jobs::EnrichmentStalenessJob::new(ctx.clone())) let job = Arc::new(application::jobs::EnrichmentStalenessJob::new(ctx.clone()))
as Arc<dyn PeriodicJob>; as Arc<dyn PeriodicJob>;
(Some(handler), Some(person_handler), Some(job)) (Some(handler), Some(person_handler), Some(job))