Search: add sort information in dashboard results (#30609)

* Search: add SortMeta in dashboard results

* fix integration tests

* trim SortMeta

* fix searchstore tests

* Update pkg/services/sqlstore/dashboard.go

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>

Co-authored-by: Emil Tullstedt <emil.tullstedt@grafana.com>
This commit is contained in:
Agnès Toulet
2021-02-11 08:49:16 +01:00
committed by GitHub
parent 25117f5af5
commit 3303e28b38
15 changed files with 111 additions and 87 deletions

View File

@@ -55,8 +55,15 @@ func (b *Builder) buildSelect() {
dashboard.folder_id,
folder.uid AS folder_uid,
folder.slug AS folder_slug,
folder.title AS folder_title
FROM `)
folder.title AS folder_title `)
for _, f := range b.Filters {
if f, ok := f.(FilterSelect); ok {
b.sql.WriteString(fmt.Sprintf(", %s", f.Select()))
}
}
b.sql.WriteString(` FROM `)
}
func (b *Builder) applyFilters() (ordering string) {

View File

@@ -33,6 +33,10 @@ type FilterLeftJoin interface {
LeftJoin() string
}
type FilterSelect interface {
Select() string
}
const (
TypeFolder = "dash-folder"
TypeDashboard = "dash-db"

View File

@@ -58,10 +58,10 @@ func TestBuilder_EqualResults_Basic(t *testing.T) {
require.NoError(t, err)
assert.Len(t, res, 1)
res[0].Uid = ""
res[0].UID = ""
assert.EqualValues(t, []sqlstore.DashboardSearchProjection{
{
Id: 1,
ID: 1,
Title: "A",
Slug: "a",
Term: "templated",