Major refactorings around searching, moved to seperate package, trying to move stuff out of models package, extend search support searching different types of entities and different types of dashboards, #960
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/metrics"
|
||||
m "github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/search"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -119,7 +120,7 @@ type DashboardSearchProjection struct {
|
||||
Term string
|
||||
}
|
||||
|
||||
func SearchDashboards(query *m.SearchDashboardsQuery) error {
|
||||
func SearchDashboards(query *search.FindPersistedDashboardsQuery) error {
|
||||
var sql bytes.Buffer
|
||||
params := make([]interface{}, 0)
|
||||
|
||||
@@ -166,17 +167,17 @@ func SearchDashboards(query *m.SearchDashboardsQuery) error {
|
||||
return err
|
||||
}
|
||||
|
||||
query.Result = make([]*m.DashboardSearchHit, 0)
|
||||
hits := make(map[int64]*m.DashboardSearchHit)
|
||||
query.Result = make([]*search.Hit, 0)
|
||||
hits := make(map[int64]*search.Hit)
|
||||
|
||||
for _, item := range res {
|
||||
hit, exists := hits[item.Id]
|
||||
if !exists {
|
||||
hit = &m.DashboardSearchHit{
|
||||
hit = &search.Hit{
|
||||
Id: item.Id,
|
||||
Title: item.Title,
|
||||
Uri: "db/" + item.Slug,
|
||||
Type: m.DashTypeDB,
|
||||
Type: search.DashHitDB,
|
||||
Tags: []string{},
|
||||
}
|
||||
query.Result = append(query.Result, hit)
|
||||
|
||||
Reference in New Issue
Block a user