Backfill tracker description from common catalog

When the mapping worker resolves a CommonTrackerPattern, propagate
its description back to the org TrackerPattern if the latter is
still empty. This ensures agent-produced descriptions reach the
user-facing tracker instead of staying only in the catalog.

The Update method now covers all mutable TrackerPattern columns
including common_tracker_pattern_id and third_party_id, replacing
the removed UpdateMapping method.

Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
Émile Ré
2026-05-28 21:59:02 +02:00
parent ed93301a1f
commit 979486020e
2 changed files with 26 additions and 47 deletions

View File

@@ -159,7 +159,19 @@ func (h *trackerMappingHandler) Process(ctx context.Context, tp coredata.Tracker
}
if commonPatternID != nil || thirdPartyID != nil {
if err := tp.UpdateMapping(ctx, tx, commonPatternID, thirdPartyID); err != nil {
tp.CommonTrackerPatternID = commonPatternID
tp.ThirdPartyID = thirdPartyID
tp.UpdatedAt = time.Now()
if tp.Description == "" && commonPatternID != nil {
var commonPattern coredata.CommonTrackerPattern
if err := commonPattern.LoadByID(ctx, tx, *commonPatternID); err == nil && commonPattern.Description != "" {
tp.Description = commonPattern.Description
}
}
scope := coredata.NewScopeFromObjectID(tp.ID)
if err := tp.Update(ctx, tx, scope); err != nil {
return fmt.Errorf("cannot update tracker pattern mapping: %w", err)
}