From 437a9eb42faad67b05a105387cbbf6da056bafc6 Mon Sep 17 00:00:00 2001 From: Matthieu 'JP' DERASSE Date: Thu, 20 Jul 2023 18:28:06 +0000 Subject: [PATCH] feat(ticker): Add ticker to env --- alert/alert.go | 10 +++++----- alert/config.go | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/alert/alert.go b/alert/alert.go index 9cd6ca2..20c403f 100644 --- a/alert/alert.go +++ b/alert/alert.go @@ -24,16 +24,16 @@ func Init(alertChan chan api.Availability) { log.Fatalf("Fail to instantiate the HTTP Client. Error: %s", err.Error()) } - priceAlertStr := os.Getenv("PRICE_ALERT") - if priceAlertStr != "" { - PriceAlert, err = strconv.ParseInt(priceAlertStr, 10, 64) + tickerInSecond := os.Getenv("TICKER_ALERT") + if tickerInSecond != "" { + ticker, err = strconv.ParseInt(tickerInSecond, 10, 64) if err != nil { - log.Fatalf("invalid configuration. PRICE_ALERT environement variable should be an integer.") + log.Fatalf("invalid configuration. TICKER_ALERT environement variable should be an integer.") } } // define an interval and the ticker for this interval - interval := time.Duration(6) * time.Second + interval := time.Duration(ticker) * time.Second // create a new Ticker tk := time.NewTicker(interval) diff --git a/alert/config.go b/alert/config.go index 532b2b5..ae2e8fc 100644 --- a/alert/config.go +++ b/alert/config.go @@ -6,6 +6,7 @@ import ( // PriceAlert contain the minimum price that will trigger an alert. var PriceAlert int64 = 47000 +var ticker int64 = 6 var carFilter api.AvailabilityQueryParams = api.AvailabilityQueryParams{ Model: "my",