From ea46401db2a32e2c8e073df342e21afa6e14e8c8 Mon Sep 17 00:00:00 2001 From: xiaoziv Date: Sat, 6 Aug 2022 18:15:04 +0800 Subject: [PATCH] remove record rule check (#1090) Co-authored-by: ziv --- src/models/recording_rule.go | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/models/recording_rule.go b/src/models/recording_rule.go index c39da861..8efddcf9 100644 --- a/src/models/recording_rule.go +++ b/src/models/recording_rule.go @@ -83,14 +83,15 @@ func (re *RecordingRule) Add() error { return err } - exists, err := RecordingRuleExists(0, re.GroupId, re.Cluster, re.Name) - if err != nil { - return err - } - - if exists { - return errors.New("RecordingRule already exists") - } + // 由于实际场景中会出现name重复的recording rule,所以不需要检查重复 + //exists, err := RecordingRuleExists(0, re.GroupId, re.Cluster, re.Name) + //if err != nil { + // return err + //} + // + //if exists { + // return errors.New("RecordingRule already exists") + //} now := time.Now().Unix() re.CreateAt = now @@ -100,15 +101,16 @@ func (re *RecordingRule) Add() error { } func (re *RecordingRule) Update(ref RecordingRule) error { - if re.Name != ref.Name { - exists, err := RecordingRuleExists(re.Id, re.GroupId, re.Cluster, ref.Name) - if err != nil { - return err - } - if exists { - return errors.New("RecordingRule already exists") - } - } + // 由于实际场景中会出现name重复的recording rule,所以不需要检查重复 + //if re.Name != ref.Name { + // exists, err := RecordingRuleExists(re.Id, re.GroupId, re.Cluster, ref.Name) + // if err != nil { + // return err + // } + // if exists { + // return errors.New("RecordingRule already exists") + // } + //} ref.FE2DB() ref.Id = re.Id