fix(monitor): modify alertrecord list input

1.修改资源类型查询参数
This commit is contained in:
zhaoxiangchun
2021-01-26 10:22:11 +08:00
parent 268a3ee71b
commit ce02a6556b
2 changed files with 9 additions and 9 deletions
+5 -5
View File
@@ -9,11 +9,11 @@ type AlertRecordListInput struct {
apis.EnabledResourceBaseListInput
apis.StatusStandaloneResourceListInput
AlertId string `json:"alert_id"`
Level string `json:"level"`
State string `json:"state"`
ResTypes []string `json:"res_types"`
Alerting bool `json:"alerting"`
AlertId string `json:"alert_id"`
Level string `json:"level"`
State string `json:"state"`
ResType string `json:"res_type"`
Alerting bool `json:"alerting"`
}
type AlertRecordDetails struct {
+4 -4
View File
@@ -110,8 +110,8 @@ func (manager *SAlertRecordManager) ListItemFilter(
} else {
q = q.IsNotEmpty("res_type").IsNotNull("res_type")
}
if len(query.ResTypes) != 0 {
q.Filter(sqlchemy.In(q.Field("res_type"), query.ResTypes))
if len(query.ResType) != 0 {
q.Filter(sqlchemy.Equals(q.Field("res_type"), query.ResType))
}
return q, nil
}
@@ -363,8 +363,8 @@ func (manager *SAlertRecordManager) getNowAlertingRecord(ctx context.Context, us
query = query.Equals("state", monitor.AlertStateAlerting)
query = query.IsNotNull("res_type").IsNotEmpty("res_type").Desc("created_at")
if len(input.ResTypes) != 0 {
query = query.In("res_type", input.ResTypes)
if len(input.ResType) != 0 {
query = query.Equals("res_type", input.ResType)
}
alertsQuery := CommonAlertManager.Query("id").Equals("state", monitor.AlertStateAlerting).IsTrue("enabled").