Chore: Remove result field from dashboards (#65249)
remove result field from dashboards
This commit is contained in:
@@ -346,11 +346,11 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := testSearchDashboards(dashboardStore, &query)
|
||||
hits, err := testSearchDashboards(dashboardStore, &query)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, len(query.Result), 1)
|
||||
hit := query.Result[0]
|
||||
require.Equal(t, len(hits), 1)
|
||||
hit := hits[0]
|
||||
require.Equal(t, hit.Type, model.DashHitFolder)
|
||||
require.Equal(t, hit.URL, fmt.Sprintf("/dashboards/f/%s/%s", savedFolder.UID, savedFolder.Slug))
|
||||
require.Equal(t, hit.FolderTitle, "")
|
||||
@@ -370,11 +370,11 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := testSearchDashboards(dashboardStore, &query)
|
||||
hits, err := testSearchDashboards(dashboardStore, &query)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, len(query.Result), 1)
|
||||
require.EqualValues(t, query.Result[0].Title, "1 test dash folder")
|
||||
require.Equal(t, len(hits), 1)
|
||||
require.EqualValues(t, hits[0].Title, "1 test dash folder")
|
||||
})
|
||||
|
||||
t.Run("Should be able to find results beyond limit using paging", func(t *testing.T) {
|
||||
@@ -395,11 +395,11 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := testSearchDashboards(dashboardStore, &query)
|
||||
hits, err := testSearchDashboards(dashboardStore, &query)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, len(query.Result), 1)
|
||||
require.EqualValues(t, query.Result[0].Title, "test dash 23")
|
||||
require.Equal(t, len(hits), 1)
|
||||
require.EqualValues(t, hits[0].Title, "test dash 23")
|
||||
})
|
||||
|
||||
t.Run("Should be able to filter by tag and type", func(t *testing.T) {
|
||||
@@ -417,11 +417,11 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := testSearchDashboards(dashboardStore, &query)
|
||||
hits, err := testSearchDashboards(dashboardStore, &query)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, len(query.Result), 3)
|
||||
require.Equal(t, query.Result[0].Title, "test dash 23")
|
||||
require.Equal(t, len(hits), 3)
|
||||
require.Equal(t, hits[0].Title, "test dash 23")
|
||||
})
|
||||
|
||||
t.Run("Should be able to find a dashboard folder's children", func(t *testing.T) {
|
||||
@@ -438,11 +438,11 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := testSearchDashboards(dashboardStore, &query)
|
||||
hits, err := testSearchDashboards(dashboardStore, &query)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, len(query.Result), 2)
|
||||
hit := query.Result[0]
|
||||
require.Equal(t, len(hits), 2)
|
||||
hit := hits[0]
|
||||
require.Equal(t, hit.ID, savedDash.ID)
|
||||
require.Equal(t, hit.URL, fmt.Sprintf("/d/%s/%s", savedDash.UID, savedDash.Slug))
|
||||
require.Equal(t, hit.FolderID, savedFolder.ID)
|
||||
@@ -464,15 +464,15 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := testSearchDashboards(dashboardStore, &query)
|
||||
hits, err := testSearchDashboards(dashboardStore, &query)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Equal(t, len(query.Result), 2)
|
||||
require.Equal(t, len(hits), 2)
|
||||
|
||||
hit := query.Result[0]
|
||||
hit := hits[0]
|
||||
require.Equal(t, len(hit.Tags), 2)
|
||||
|
||||
hit2 := query.Result[1]
|
||||
hit2 := hits[1]
|
||||
require.Equal(t, len(hit2.Tags), 1)
|
||||
})
|
||||
|
||||
@@ -751,17 +751,17 @@ func updateDashboardACL(t *testing.T, dashboardStore dashboards.Store, dashboard
|
||||
|
||||
// testSearchDashboards is a (near) copy of the dashboard service
|
||||
// SearchDashboards, which is a wrapper around FindDashboards.
|
||||
func testSearchDashboards(d dashboards.Store, query *dashboards.FindPersistedDashboardsQuery) error {
|
||||
func testSearchDashboards(d dashboards.Store, query *dashboards.FindPersistedDashboardsQuery) (model.HitList, error) {
|
||||
res, err := d.FindDashboards(context.Background(), query)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
makeQueryResult(query, res)
|
||||
return nil
|
||||
hits := makeQueryResult(query, res)
|
||||
return hits, nil
|
||||
}
|
||||
|
||||
func makeQueryResult(query *dashboards.FindPersistedDashboardsQuery, res []dashboards.DashboardSearchProjection) {
|
||||
query.Result = make([]*model.Hit, 0)
|
||||
func makeQueryResult(query *dashboards.FindPersistedDashboardsQuery, res []dashboards.DashboardSearchProjection) model.HitList {
|
||||
hitList := make([]*model.Hit, 0)
|
||||
hits := make(map[int64]*model.Hit)
|
||||
|
||||
for _, item := range res {
|
||||
@@ -794,11 +794,12 @@ func makeQueryResult(query *dashboards.FindPersistedDashboardsQuery, res []dashb
|
||||
hit.SortMetaName = query.Sort.MetaName
|
||||
}
|
||||
|
||||
query.Result = append(query.Result, hit)
|
||||
hitList = append(hitList, hit)
|
||||
hits[item.ID] = hit
|
||||
}
|
||||
if len(item.Term) > 0 {
|
||||
hit.Tags = append(hit.Tags, item.Term)
|
||||
}
|
||||
}
|
||||
return hitList
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user