Skip to content

Commit

Permalink
chore: dedup component relationship rows
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra authored and moshloop committed Oct 10, 2024
1 parent 36b8f7e commit 8c4cc37
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/topology/component_relationship.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package topology
import (
"fmt"

"github.com/flanksource/commons/collections"
"github.com/flanksource/duty"
"github.com/flanksource/duty/context"
dutydb "github.com/flanksource/duty/db"
Expand Down Expand Up @@ -54,10 +55,11 @@ var ComponentRelationshipSync = &job.Job{
continue
}
relationships := []models.ComponentRelationship{}
for _, c := range comps {
compIDs := collections.Dedup(lo.Map(comps, func(comp models.Component, _ int) uuid.UUID { return comp.ID }))
for _, cID := range compIDs {
relationships = append(relationships, models.ComponentRelationship{
RelationshipID: component.ID,
ComponentID: c.ID,
ComponentID: cID,
SelectorID: hash,
RelationshipPath: component.Path + "." + component.ID.String(),
})
Expand Down

0 comments on commit 8c4cc37

Please sign in to comment.