mirror of
https://github.com/prymitive/karma
synced 2026-05-07 03:26:52 +00:00
Now that models package contains only unsee specific models rename everything stripping Unsee prefix from names
25 lines
709 B
Go
25 lines
709 B
Go
package transform
|
|
|
|
import (
|
|
"github.com/cloudflare/unsee/filters"
|
|
"github.com/cloudflare/unsee/models"
|
|
)
|
|
|
|
// BuildAutocomplete takes an alert object and generates list of autocomplete
|
|
// strings for it
|
|
func BuildAutocomplete(alerts []models.Alert) []models.Autocomplete {
|
|
acHints := map[string]models.Autocomplete{}
|
|
for _, filterConfig := range filters.AllFilters {
|
|
if filterConfig.Autocomplete != nil {
|
|
for _, hint := range filterConfig.Autocomplete(filterConfig.Label, filterConfig.SupportedOperators, alerts) {
|
|
acHints[hint.Value] = hint
|
|
}
|
|
}
|
|
}
|
|
acHintsSlice := []models.Autocomplete{}
|
|
for _, hint := range acHints {
|
|
acHintsSlice = append(acHintsSlice, hint)
|
|
}
|
|
return acHintsSlice
|
|
}
|