1
0
Fork 0

explicitly set max_time when querying activities
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Massaki Archambault 2021-10-12 09:35:31 -04:00
parent fd43e3751f
commit 02811497b6
6 changed files with 10 additions and 16 deletions

View File

@ -518,7 +518,9 @@ func (e *Exporter) collectAccountTransactionsMetrics(wg *sync.WaitGroup, ch chan
// add 1 second to the last update time to avoid querying the same activity twice
minTime := account.Tx.LastUpdate.Add(time.Second * 1)
activities, err := heliumapi.GetActivityForAccount(account.Address, activityTypes, &minTime, nil)
// Explicitly set max_time, to avoid issues with server-side caching
maxTime := time.Now()
activities, err := heliumapi.GetActivityForAccount(account.Address, activityTypes, &minTime, &maxTime)
if err != nil {
log.Println(err)
return

View File

@ -37,10 +37,10 @@ func GetActivityForAccount(account string, filterTypes []string, minTime *time.T
params["min_time"] = strings.Join(filterTypes, ",")
}
if minTime != nil {
params["min_time"] = minTime.UTC().Format(timeFormat)
params["min_time"] = minTime.UTC().Format(time.RFC3339)
}
if maxTime != nil {
params["max_time"] = maxTime.UTC().Format(timeFormat)
params["max_time"] = maxTime.UTC().Format(time.RFC3339)
}
// query the api
@ -88,10 +88,10 @@ func GetRewardTotalsForAccount(account string, minTime *time.Time, maxTime *time
path := "/v1/accounts/" + account + "/rewards/sum"
params := map[string]string{}
if minTime != nil {
params["min_time"] = minTime.UTC().Format(timeFormat)
params["min_time"] = minTime.UTC().Format(time.RFC3339)
}
if maxTime != nil {
params["max_time"] = maxTime.UTC().Format(timeFormat)
params["max_time"] = maxTime.UTC().Format(time.RFC3339)
}
// query the api

View File

@ -12,7 +12,7 @@ func GetHeight(maxTime *time.Time) (int, error) {
path := "/v1/blocks/height"
params := map[string]string{}
if maxTime != nil {
params["max_time"] = maxTime.UTC().Format(timeFormat)
params["max_time"] = maxTime.UTC().Format(time.RFC3339)
}
// query the api

View File

@ -31,10 +31,10 @@ func GetRewardsTotalForHotspot(hotspot string, minTime *time.Time, maxTime *time
path := "/v1/hotspots/" + hotspot + "/rewards/sum"
params := map[string]string{}
if minTime != nil {
params["min_time"] = minTime.UTC().Format(timeFormat)
params["min_time"] = minTime.UTC().Format(time.RFC3339)
}
if maxTime != nil {
params["max_time"] = maxTime.UTC().Format(timeFormat)
params["max_time"] = maxTime.UTC().Format(time.RFC3339)
}
// query the api

View File

@ -6,7 +6,6 @@ import (
"io/ioutil"
"log"
"net/http"
"strings"
)
var (

View File

@ -1,12 +1,5 @@
package heliumapi
const (
// WORKAROUND: for some reason, helium api partially breaks when given the timezone information
// in "max_time" and "min_time", even if the example code suggest that it supports it.
// For this reason, we cannot use time.RFC3339 as the time format.
timeFormat = "2006-01-02T15:04:05Z"
)
type AccountResp struct {
Data Account `json:"data"`
}