mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 20:42:40 +08:00

* Add search index table * Stab a test * Add more tests * Add basic index * Switch to UID and add a test for the index * Improve tests coverage * Remove redundant whitespaces * Load all data source APIs when query history is loaded * Fix column type * Fix migration * Clean-up the index * Fix linting * Fix migrations * Fix migrations * Fix migrations * Rename index to details
37 lines
628 B
Go
37 lines
628 B
Go
package queryhistory
|
|
|
|
import (
|
|
"encoding/json"
|
|
"slices"
|
|
|
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
|
)
|
|
|
|
type DataQuery struct {
|
|
Datasource Datasource `json:"datasource"`
|
|
}
|
|
|
|
func FindDataSourceUIDs(queriesJSON *simplejson.Json) ([]string, error) {
|
|
uids := make([]string, 0)
|
|
queries := []DataQuery{}
|
|
bytes, err := queriesJSON.ToDB()
|
|
|
|
if err != nil {
|
|
return uids, err
|
|
}
|
|
|
|
err = json.Unmarshal(bytes, &queries)
|
|
|
|
if err != nil {
|
|
return uids, err
|
|
}
|
|
|
|
for _, query := range queries {
|
|
if !slices.Contains(uids, query.Datasource.UID) {
|
|
uids = append(uids, query.Datasource.UID)
|
|
}
|
|
}
|
|
|
|
return uids, nil
|
|
}
|