Browse Source

fix device fetch returning duplicate results if overlapping tags are supplied.

pull/1/head
Gisle Aune 3 years ago
parent
commit
d623647e21
  1. 6
      internal/mysql/devicerepo.go

6
internal/mysql/devicerepo.go

@ -296,8 +296,13 @@ func (r *DeviceRepo) populate(ctx context.Context, records []deviceRecord) ([]mo
return nil, dbErr(err) return nil, dbErr(err)
} }
hasAdded := make(map[int]bool, len(records))
devices := make([]models.Device, 0, len(records)) devices := make([]models.Device, 0, len(records))
for _, record := range records { for _, record := range records {
if hasAdded[record.ID] {
continue
}
device := models.Device{ device := models.Device{
ID: record.ID, ID: record.ID,
BridgeID: record.BridgeID, BridgeID: record.BridgeID,
@ -361,6 +366,7 @@ func (r *DeviceRepo) populate(ctx context.Context, records []deviceRecord) ([]mo
} }
} }
hasAdded[record.ID] = true
devices = append(devices, device) devices = append(devices, device)
} }

Loading…
Cancel
Save