Chore: Remove result field from search (#65583)
remove result field from search
This commit is contained in:
+2
-2
@@ -116,12 +116,12 @@ func (hs *HTTPServer) GetAlerts(c *contextmodel.ReqContext) response.Response {
|
||||
Permission: dashboards.PERMISSION_VIEW,
|
||||
}
|
||||
|
||||
err := hs.SearchService.SearchHandler(c.Req.Context(), &searchQuery)
|
||||
hits, err := hs.SearchService.SearchHandler(c.Req.Context(), &searchQuery)
|
||||
if err != nil {
|
||||
return response.Error(500, "List alerts failed", err)
|
||||
}
|
||||
|
||||
for _, d := range searchQuery.Result {
|
||||
for _, d := range hits {
|
||||
if d.Type == model.DashHitDB && d.ID > 0 {
|
||||
dashboardIDs = append(dashboardIDs, d.ID)
|
||||
}
|
||||
|
||||
@@ -320,9 +320,8 @@ type setUpConf struct {
|
||||
|
||||
type mockSearchService struct{ ExpectedResult model.HitList }
|
||||
|
||||
func (mss *mockSearchService) SearchHandler(_ context.Context, q *search.Query) error {
|
||||
q.Result = mss.ExpectedResult
|
||||
return nil
|
||||
func (mss *mockSearchService) SearchHandler(_ context.Context, q *search.Query) (model.HitList, error) {
|
||||
return mss.ExpectedResult, nil
|
||||
}
|
||||
func (mss *mockSearchService) SortOptions() []model.SortOption { return nil }
|
||||
|
||||
|
||||
+3
-2
@@ -350,13 +350,14 @@ func (hs *HTTPServer) searchFolders(c *contextmodel.ReqContext) ([]*folder.Folde
|
||||
Page: c.QueryInt64("page"),
|
||||
}
|
||||
|
||||
if err := hs.SearchService.SearchHandler(c.Req.Context(), &searchQuery); err != nil {
|
||||
hits, err := hs.SearchService.SearchHandler(c.Req.Context(), &searchQuery)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
folders := make([]*folder.Folder, 0)
|
||||
|
||||
for _, hit := range searchQuery.Result {
|
||||
for _, hit := range hits {
|
||||
folders = append(folders, &folder.Folder{
|
||||
ID: hit.ID,
|
||||
UID: hit.UID,
|
||||
|
||||
@@ -52,8 +52,9 @@ func (hs *HTTPServer) populateDashboardsByTag(ctx context.Context, orgID int64,
|
||||
OrgId: orgID,
|
||||
}
|
||||
|
||||
if err := hs.SearchService.SearchHandler(ctx, &searchQuery); err == nil {
|
||||
for _, item := range searchQuery.Result {
|
||||
hits, err := hs.SearchService.SearchHandler(ctx, &searchQuery)
|
||||
if err == nil {
|
||||
for _, item := range hits {
|
||||
result = append(result, dtos.PlaylistDashboard{
|
||||
Id: item.ID,
|
||||
Slug: item.Slug,
|
||||
|
||||
+3
-3
@@ -81,7 +81,7 @@ func (hs *HTTPServer) Search(c *contextmodel.ReqContext) response.Response {
|
||||
Sort: sort,
|
||||
}
|
||||
|
||||
err := hs.SearchService.SearchHandler(c.Req.Context(), &searchQuery)
|
||||
hits, err := hs.SearchService.SearchHandler(c.Req.Context(), &searchQuery)
|
||||
if err != nil {
|
||||
return response.Error(500, "Search failed", err)
|
||||
}
|
||||
@@ -89,10 +89,10 @@ func (hs *HTTPServer) Search(c *contextmodel.ReqContext) response.Response {
|
||||
defer c.TimeRequest(metrics.MApiDashboardSearch)
|
||||
|
||||
if !c.QueryBool("accesscontrol") {
|
||||
return response.JSON(http.StatusOK, searchQuery.Result)
|
||||
return response.JSON(http.StatusOK, hits)
|
||||
}
|
||||
|
||||
return hs.searchHitsWithMetadata(c, searchQuery.Result)
|
||||
return hs.searchHitsWithMetadata(c, hits)
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) searchHitsWithMetadata(c *contextmodel.ReqContext, hits model.HitList) response.Response {
|
||||
|
||||
Reference in New Issue
Block a user