update id to string
This commit is contained in:
parent
038e60b7b8
commit
0c5be6cf37
|
@ -59,6 +59,7 @@ func (h *APIHandler) HandleAddCommonCommandAction(w http.ResponseWriter, req *ht
|
|||
|
||||
h.WriteJSON(w, resBody,http.StatusOK)
|
||||
}
|
||||
|
||||
func (h *APIHandler) HandleSaveCommonCommandAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||
resBody := map[string]interface{}{
|
||||
}
|
||||
|
@ -83,7 +84,7 @@ func (h *APIHandler) HandleSaveCommonCommandAction(w http.ResponseWriter, req *h
|
|||
h.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
if len(searchRes.Hits.Hits) > 0 && searchRes.Hits.Hits[0].ID.(string) != reqParams.ID {
|
||||
if len(searchRes.Hits.Hits) > 0 && searchRes.Hits.Hits[0].ID != reqParams.ID {
|
||||
resBody["error"] = "title already exists"
|
||||
log.Error(resBody["error"])
|
||||
h.WriteJSON(w, resBody, http.StatusInternalServerError)
|
||||
|
|
|
@ -9,10 +9,10 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"infini.sh/console/model"
|
||||
httprouter "infini.sh/framework/core/api/router"
|
||||
"infini.sh/framework/core/elastic"
|
||||
"infini.sh/framework/core/util"
|
||||
"infini.sh/console/model"
|
||||
)
|
||||
|
||||
func (handler APIHandler) HandleReindexAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||
|
@ -158,7 +158,7 @@ func SyncRebuildResult(esName string) error {
|
|||
)
|
||||
for _, doc := range taskResp.Hits.Hits {
|
||||
status = model.ReindexStatusRunning
|
||||
source := esRes.Hits.Hits[idMap[doc.ID.(string)]].Source
|
||||
source := esRes.Hits.Hits[idMap[doc.ID]].Source
|
||||
if _, ok := doc.Source["error"]; ok {
|
||||
status = model.ReindexStatusFailed
|
||||
} else {
|
||||
|
@ -166,7 +166,7 @@ func SyncRebuildResult(esName string) error {
|
|||
}
|
||||
source["status"] = status
|
||||
source["task_source"] = doc.Source
|
||||
_, err := client.Index(orm.GetIndexName(model.Reindex{}), "", esRes.Hits.Hits[idMap[doc.ID.(string)]].ID, source)
|
||||
_, err := client.Index(orm.GetIndexName(model.Reindex{}), "", esRes.Hits.Hits[idMap[doc.ID]].ID, source)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -151,7 +151,7 @@ func getTopTenAlertCluster()(interface{}, error){
|
|||
res.Body.Close()
|
||||
clusterMap := IfaceMap{}
|
||||
for _, hit := range resBody.Hits.Hits {
|
||||
clusterMap[hit.ID.(string)] = hit.Source["name"]
|
||||
clusterMap[hit.ID] = hit.Source["name"]
|
||||
}
|
||||
for _, d := range metricData {
|
||||
if name, ok := clusterMap[d["x"].(string)]; ok {
|
||||
|
|
|
@ -10,12 +10,12 @@ import (
|
|||
"github.com/elastic/go-ucfg/yaml"
|
||||
cronlib "github.com/robfig/cron"
|
||||
"github.com/valyala/fasttemplate"
|
||||
"infini.sh/framework/core/conditions"
|
||||
"infini.sh/framework/core/elastic"
|
||||
"infini.sh/framework/core/orm"
|
||||
"infini.sh/console/model/alerting"
|
||||
"infini.sh/console/service/alerting/action"
|
||||
"infini.sh/console/service/alerting/util"
|
||||
"infini.sh/framework/core/conditions"
|
||||
"infini.sh/framework/core/elastic"
|
||||
"infini.sh/framework/core/orm"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
@ -370,7 +370,7 @@ func saveAlertInfo(alertItem *alerting.Alert) error {
|
|||
return err
|
||||
}
|
||||
currentState := queryValue(resBody.Hits.Hits[0].Source, "state", "").(string)
|
||||
alertItem.Id = resBody.Hits.Hits[0].ID.(string)
|
||||
alertItem.Id = resBody.Hits.Hits[0].ID
|
||||
if currentState != alertItem.State {
|
||||
reqUrl = fmt.Sprintf("%s/%s/_doc/%s", conf.Endpoint, getAlertIndexName(INDEX_ALERT_HISTORY), alertItem.Id)
|
||||
source := resBody.Hits.Hits[0].Source
|
||||
|
@ -381,7 +381,7 @@ func saveAlertInfo(alertItem *alerting.Alert) error {
|
|||
}
|
||||
}
|
||||
_,err = doRequest(reqUrl, http.MethodPut, nil, source)
|
||||
reqUrl = fmt.Sprintf("%s/%s/_doc/%s", conf.Endpoint, indexName, resBody.Hits.Hits[0].ID.(string))
|
||||
reqUrl = fmt.Sprintf("%s/%s/_doc/%s", conf.Endpoint, indexName, resBody.Hits.Hits[0].ID)
|
||||
_,err = doRequest(reqUrl, http.MethodDelete, nil, alertItem)
|
||||
return err
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ func getEnabledMonitors() (map[string]ScheduleMonitor, error){
|
|||
monitor := &alerting.Monitor{}
|
||||
buf, _ := json.Marshal(hit.Source[MONITOR_FIELD])
|
||||
_ = json.Unmarshal(buf, monitor)
|
||||
monitors[hit.ID.(string)] = ScheduleMonitor{
|
||||
monitors[hit.ID] = ScheduleMonitor{
|
||||
Monitor: monitor,
|
||||
ClusterID: hit.Source["cluster_id"].(string),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue