Skip to content

Commit 185cb68

Browse files
author
sw33tLie
committed
fix ai variants in updates page
1 parent d6c8289 commit 185cb68

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

pkg/storage/storage.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,35 @@ func (d *DB) UpsertProgramEntries(ctx context.Context, programURL, platform, han
799799
}
800800
}
801801

802+
// Deduplicate AI variant changes: when the same AI-normalized value appears as a
803+
// variant on multiple raw targets, each generates a change entry. We keep only one
804+
// change per unique (TargetAINormalized, Category, ChangeType) to avoid duplicate
805+
// entries in the updates feed.
806+
if len(changes) > 0 {
807+
type aiChangeKey struct {
808+
aiNormalized string
809+
category string
810+
changeType string
811+
}
812+
seen := make(map[aiChangeKey]bool)
813+
deduped := make([]Change, 0, len(changes))
814+
for _, c := range changes {
815+
if c.TargetAINormalized != "" {
816+
k := aiChangeKey{
817+
aiNormalized: strings.ToLower(c.TargetAINormalized),
818+
category: strings.ToLower(c.Category),
819+
changeType: c.ChangeType,
820+
}
821+
if seen[k] {
822+
continue
823+
}
824+
seen[k] = true
825+
}
826+
deduped = append(deduped, c)
827+
}
828+
changes = deduped
829+
}
830+
802831
return changes, nil
803832
}
804833

0 commit comments

Comments
 (0)