fix(api): publish OccurrenceCreatedEvent on face assignment + backfill embeddings #640
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/occurrence-event"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Three fixes for missing people/suggestions/thumbnails after face assignment:
1. PRIMARY:
upsertGenericPeopleOccurrencenow publishesOccurrenceCreatedEventPreviously: faces assigned via new endpoint never triggered
PendingEmbeddingFlushListener. Embeddings stuck inpending_face_embeddingsforever (or 5 min via scheduler).Now:
ClassInstanceServiceinjectsApplicationEventPublisher.upsertGenericPeopleOccurrencepublishes event on successful INSERT. Embeddings flush immediately.2. Auto-set
representative_occurrence_idonclass_instancesPreviously: people with assigned faces had no representative set → no thumbnail.
Now: when first occurrence is created,
representative_occurrence_idis auto-set if currently null.3. Name-based fallback in
suggestSimilarInstancesreturns real dataPreviously: fallback hard-coded
occurrenceCount=0+thumbnailUrl=null.Now: fallback SQL queries real
occurrence_count+thumbnail_urlvia correlated subquery.4. V118 migration: backfill
class_occurrence_embeddingsfor existing dataFor already-assigned faces with pending embeddings, the migration moves them to
class_occurrence_embeddingsand cleans up the pending table. Adds idempotentUNIQUE (occurrence_id, model_name, model_version)constraint needed forON CONFLICT DO NOTHING.Test
Version
1.21.4 → 1.21.5
Symptoms resolved
occurrenceCount(not 0)