Ver Fonte

Merge pull request #598 from open-falcon/fix-pr-515

fix grafana query endpoint api, use gorm method instead of concat sql
MistShi há 6 anos atrás
pai
commit
a56b02f5e5
1 ficheiros alterados com 1 adições e 4 exclusões
  1. 1 4
      modules/api/app/controller/graph/grafana_controller.go

+ 1 - 4
modules/api/app/controller/graph/grafana_controller.go

@@ -162,10 +162,7 @@ func findEndpointIdByEndpointList(hosts []string) []int64 {
 	//for get right table name
 	enpsHelp := m.Endpoint{}
 	enps := []m.Endpoint{}
-	hostStr, _ := u.ArrStringsToString(hosts)
-	log.Debugf("hostStr: %v", hostStr)
-	log.Debugf("endpoint in (%s)", hostStr)
-	db.Graph.Table(enpsHelp.TableName()).Where(fmt.Sprintf("endpoint in (%s)", hostStr)).Scan(&enps)
+	db.Graph.Table(enpsHelp.TableName()).Where("endpoint in (?)", hosts).Scan(&enps)
 	hostIds := make([]int64, len(enps))
 	for indx, h := range enps {
 		hostIds[indx] = int64(h.ID)