From d3be6ca49c9f6ddda5a35fae66f45fe2a43a9eff Mon Sep 17 00:00:00 2001 From: Matthieu 'JP' DERASSE Date: Wed, 21 Jun 2023 13:50:27 +0000 Subject: [PATCH] fix(alert): alert only once --- alert/alert.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/alert/alert.go b/alert/alert.go index 6d54d67..0b2866e 100644 --- a/alert/alert.go +++ b/alert/alert.go @@ -66,22 +66,26 @@ func checkPrice(alertChan chan api.Availability) { return } + StdAlert := false + LrAlert := false for _, availability := range availabilities.Results { if availability.IsDemo { continue } - if availability.Price < 39000 && availability.Trim[0] == "SRRWD" { + if !StdAlert && availability.Price < 39000 && availability.Trim[0] == "SRRWD" { log.Info("Launching an alert !") alertChan <- availability alert++ + StdAlert = true } - if availability.Price < 47000 && availability.Trim[0] == "LRAWD" { + if !LrAlert && availability.Price < 47000 && availability.Trim[0] == "LRAWD" { log.Info("Launching an alert !") alertChan <- availability alert++ + LrAlert = true } } }