remove bus from search and avoid import cycle (#46789)

* fix the import cicle

* fix some unittest

* fix removal bus from search
This commit is contained in:
ying-jeanne
2022-03-21 23:54:30 +08:00
committed by GitHub
parent 8199cc0cf8
commit 0d5a6c2194
13 changed files with 137 additions and 137 deletions
+2 -2
View File
@@ -89,7 +89,7 @@ func (hs *HTTPServer) GetAlerts(c *models.ReqContext) response.Response {
Limit: 1000,
OrgId: c.OrgId,
DashboardIds: dashboardIDs,
Type: string(search.DashHitDB),
Type: string(models.DashHitDB),
FolderIds: folderIDs,
Permission: models.PERMISSION_VIEW,
}
@@ -100,7 +100,7 @@ func (hs *HTTPServer) GetAlerts(c *models.ReqContext) response.Response {
}
for _, d := range searchQuery.Result {
if d.Type == search.DashHitDB && d.ID > 0 {
if d.Type == models.DashHitDB && d.ID > 0 {
dashboardIDs = append(dashboardIDs, d.ID)
}
}
+5 -5
View File
@@ -27,13 +27,13 @@ type setUpConf struct {
aclMockResp []*models.DashboardAclInfoDTO
}
type mockSearchService struct{ ExpectedResult search.HitList }
type mockSearchService struct{ ExpectedResult models.HitList }
func (mss *mockSearchService) SearchHandler(_ context.Context, q *search.Query) error {
q.Result = mss.ExpectedResult
return nil
}
func (mss *mockSearchService) SortOptions() []search.SortOption { return nil }
func (mss *mockSearchService) SortOptions() []models.SortOption { return nil }
func setUp(confs ...setUpConf) *HTTPServer {
singleAlert := &models.Alert{Id: 1, DashboardId: 1, Name: "singlealert"}
@@ -94,9 +94,9 @@ func TestAlertingAPIEndpoint(t *testing.T) {
loggedInUserScenarioWithRole(t, "When calling GET on", "GET",
"/api/alerts?dashboardId=1&dashboardId=2&folderId=3&dashboardTag=abc&dashboardQuery=dbQuery&limit=5&query=alertQuery",
"/api/alerts", models.ROLE_EDITOR, func(sc *scenarioContext) {
hs.SearchService.(*mockSearchService).ExpectedResult = search.HitList{
&search.Hit{ID: 1},
&search.Hit{ID: 2},
hs.SearchService.(*mockSearchService).ExpectedResult = models.HitList{
&models.Hit{ID: 1},
&models.Hit{ID: 2},
}
sc.handlerFunc = hs.GetAlerts
+2 -2
View File
@@ -1,6 +1,6 @@
package definitions
import "github.com/grafana/grafana/pkg/services/search"
import "github.com/grafana/grafana/pkg/models"
// swagger:route GET /search/sorting search searchSorting
//
@@ -75,7 +75,7 @@ type SearchParameters struct {
// swagger:response searchResponse
type SearchResponse struct {
// in: body
Body search.HitList `json:"body"`
Body models.HitList `json:"body"`
}
// swagger:response searchSortingResponse