From de4595837f9f3dd638d19163010e9645920790c7 Mon Sep 17 00:00:00 2001 From: Samuel Lucidi Date: Thu, 12 Oct 2023 10:46:56 -0400 Subject: [PATCH] :bug: Deduplicate tags on imported apps (#517) Signed-off-by: Sam Lucidi --- importer/manager.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/importer/manager.go b/importer/manager.go index 3b1487539..96bc78732 100644 --- a/importer/manager.go +++ b/importer/manager.go @@ -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 @@ -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)