From e30adee9b4543db6274a3bb0fd9a43d2f7aef1ab Mon Sep 17 00:00:00 2001 From: MoFan Date: Tue, 5 Sep 2023 12:36:20 +0000 Subject: [PATCH 1/2] chore: .gitignore --- .DS_Store | Bin 6148 -> 0 bytes .gitignore | 16 +++++++++++----- go.mod | 1 - internal/pkg/packets/.DS_Store | Bin 6148 -> 0 bytes 4 files changed, 11 insertions(+), 6 deletions(-) delete mode 100644 .DS_Store delete mode 100644 internal/pkg/packets/.DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 6823d8e279b80fd2c8d5b369c5d025faa5297fec..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKI|>3Z5S>vG!N$@uSMUZw^aOhWLB&E*5VYRPb9pr1d>UQtw2?P3dC6p6LSC`6 zBO*G#Y-S=85gEY^sAlb| WO>6_5j=0l-{24G^XjI_W3OoSIFcp>n diff --git a/.gitignore b/.gitignore index e515e0a..a307657 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,15 @@ +## IDE .idea +.vscode + +## golang vendor logs go.sum -manifest -cmd/.DS_Store -cmd/hummingbird-ui/.DS_Store -hummingbird -mqtt-broker \ No newline at end of file + +## MacOS +.DS_Store + +## binary +cmd/hummingbird-core/hummingbird-core +cmd/mqtt-broker/mqtt-broker \ No newline at end of file diff --git a/go.mod b/go.mod index 8507510..5181408 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.18 require ( github.com/BurntSushi/toml v1.1.0 - github.com/alexmullins/zip v0.0.0-20180717182244-4affb64b04d0 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/docker/distribution v2.8.1+incompatible github.com/docker/docker v20.10.17+incompatible diff --git a/internal/pkg/packets/.DS_Store b/internal/pkg/packets/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Tue, 5 Sep 2023 17:10:03 +0000 Subject: [PATCH 2/2] fix: EkuiperAlert api alert bug. --- .../application/alertcentreapp/alertapp.go | 41 +++++++------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/internal/hummingbird/core/application/alertcentreapp/alertapp.go b/internal/hummingbird/core/application/alertcentreapp/alertapp.go index 7ad46e0..75bc303 100644 --- a/internal/hummingbird/core/application/alertcentreapp/alertapp.go +++ b/internal/hummingbird/core/application/alertcentreapp/alertapp.go @@ -800,36 +800,25 @@ func (p alertApp) AddAlert(ctx context.Context, req map[string]interface{}) erro } } + if alertRule.SilenceTime > 0 { + alertSend, err := p.dbClient.AlertListLastSend(alertRule.Id) + if err != nil { + if !errors.Is(err, gorm.ErrRecordNotFound) { + // 处理不是记录未找到的情况 + return err + } + } else { + if alertSend.Created+alertRule.SilenceTime > utils.MakeTimestamp() { + // 在静默期内,不发送 + return nil + } + } + } + var alertList models.AlertList alertList.AlertRuleId = alertRule.Id alertList.AlertResult = alertResult alertList.TriggerTime = time.Now().UnixMilli() - - send := false - if alertRule.SilenceTime > 0 { - alertSend, err := p.dbClient.AlertListLastSend(alertRule.Id) - if err != nil { - if err == gorm.ErrRecordNotFound { - send = true - goto Jump - } - } else { - if alertSend.Created+alertRule.SilenceTime <= utils.MakeTimestamp() { - send = true - goto Jump - } - } - } - -Jump: - if send == false { - alertList.IsSend = false - _, err = p.dbClient.AddAlertList(alertList) - if err != nil { - return err - } - return nil - } alertList.IsSend = true alertList.Status = constants.Untreated