fix: close search index consistency gaps (orphan cleanup, discovery indexing, poster sync)

This commit is contained in:
2026-05-12 19:05:22 +02:00
parent 3fc7f914af
commit 2fd8734d23
11 changed files with 141 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
use domain::{
errors::DomainError,
events::DomainEvent,
models::IndexableDocument,
value_objects::{ExternalMetadataId, MovieId, PosterPath},
};
@@ -53,5 +54,19 @@ pub async fn execute(ctx: &AppContext, cmd: SyncPosterCommand) -> Result<(), Dom
movie.update_poster(poster_path);
ctx.movie_repository.upsert_movie(&movie).await?;
// Refresh search index so the new poster_path is reflected immediately.
// Fetch existing profile if available for a complete index document.
let profile = ctx.movie_profile_repository.get_by_movie_id(&movie_id).await.ok().flatten();
if let Err(e) = ctx.search_command
.index(IndexableDocument::Movie {
id: movie_id.clone(),
movie: Box::new(movie),
profile: profile.map(Box::new),
})
.await
{
tracing::warn!(movie_id = %movie_id.value(), "failed to refresh search index after poster sync: {e}");
}
Ok(())
}