Skip to content

Commit

Permalink
🐛 Deduplicate tags on imported apps (#517)
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Lucidi <slucidi@redhat.com>
  • Loading branch information
mansam committed Oct 12, 2023
1 parent aae707c commit 49e509b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions importer/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func (m *Manager) createApplication(imp *model.Import) (ok bool) {
db := m.DB.Preload("Category")
db.Find(&allTags)

seenTags := make(map[uint]bool)
appTags := []model.ApplicationTag{}
for _, impTag := range imp.ImportTags {
// Prepare normalized names for importTag
Expand Down Expand Up @@ -270,8 +271,10 @@ func (m *Manager) createApplication(imp *model.Import) (ok bool) {
return
}
}

appTags = append(appTags, model.ApplicationTag{TagID: tag.ID, Source: ""})
if !seenTags[tag.ID] {
seenTags[tag.ID] = true
appTags = append(appTags, model.ApplicationTag{TagID: tag.ID, Source: ""})
}
}

result := m.DB.Create(app)
Expand Down

0 comments on commit 49e509b

Please sign in to comment.