From bdb2a85ae54fd7ae09d9ed32409a8793da9f1c26 Mon Sep 17 00:00:00 2001 From: zhaoxiangchun <1422928955@qq.com> Date: Wed, 11 Aug 2021 12:03:06 +0800 Subject: [PATCH] fix(monitor): add used_by list filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 支持其他全服务通过used_by 字段进行相关过滤 --- pkg/apis/monitor/commalert.go | 1 + pkg/monitor/models/commonalert.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/apis/monitor/commalert.go b/pkg/apis/monitor/commalert.go index 9842d064d8..d528f82702 100644 --- a/pkg/apis/monitor/commalert.go +++ b/pkg/apis/monitor/commalert.go @@ -100,6 +100,7 @@ type CommonAlertListInput struct { Level string `json:"level"` ResType []string `json:"res_type"` + UsedBy string `json:"used_by"` } type CommonAlertUpdateInput struct { diff --git a/pkg/monitor/models/commonalert.go b/pkg/monitor/models/commonalert.go index 9deedc69a9..64cda5ec82 100644 --- a/pkg/monitor/models/commonalert.go +++ b/pkg/monitor/models/commonalert.go @@ -408,7 +408,11 @@ func (man *SCommonAlertManager) ListItemFilter( } func (man *SCommonAlertManager) FieldListFilter(q *sqlchemy.SQuery, input monitor.CommonAlertListInput) { - q.Filter(sqlchemy.IsNull(q.Field("used_by"))) + if len(input.UsedBy) == 0 { + q.Filter(sqlchemy.IsNull(q.Field("used_by"))) + } else { + q.Equals("used_by", input.UsedBy) + } if len(input.Level) > 0 { q.Equals("level", input.Level)