Awattar: fetch more than 24h price data (#16338)

This commit is contained in:
andi0b 2024-09-27 10:06:57 +02:00 • committed by GitHub
parent d53ead0f36
commit 4af2d19da3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,8 +62,14 @@ func (t *Awattar) run(done chan error) {
for ; true; <-tick.C {
var res awattar.Prices
// Awattar publishes prices for next day around 13:00 CET/CEST, so up to 35h of price data are available
// To be on the safe side request a window of -2h and +48h, the API doesn't mind requesting more than available
start := time.Now().Add(-2 * time.Hour).UnixMilli()
end := time.Now().Add(48 * time.Hour).UnixMilli()
uri := fmt.Sprintf("%s?start=%d&end=%d", t.uri, start, end)
if err := backoff.Retry(func() error {
return backoffPermanentError(client.GetJSON(t.uri, &res))
return backoffPermanentError(client.GetJSON(uri, &res))
}, bo()); err != nil {
once.Do(func() { done <- err })