From e8a8d121fb2d198e115ef050bf4ecc3c95b306aa Mon Sep 17 00:00:00 2001 From: zhaoxiangchun <1422928955@qq.com> Date: Tue, 26 Jan 2021 10:22:11 +0800 Subject: [PATCH] fix(monitor): modify alertrecord list input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.修改资源类型查询参数 --- pkg/apis/monitor/alertrecord.go | 10 +++++----- pkg/monitor/models/alertrecord.go | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/pkg/apis/monitor/alertrecord.go b/pkg/apis/monitor/alertrecord.go index d0af8ceea4..3577f13289 100644 --- a/pkg/apis/monitor/alertrecord.go +++ b/pkg/apis/monitor/alertrecord.go @@ -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 { diff --git a/pkg/monitor/models/alertrecord.go b/pkg/monitor/models/alertrecord.go index 2be0587b86..19e8bfc35f 100644 --- a/pkg/monitor/models/alertrecord.go +++ b/pkg/monitor/models/alertrecord.go @@ -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").