explicitly set max_time when querying activities
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
fd43e3751f
commit
02811497b6
|
@ -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
|
// add 1 second to the last update time to avoid querying the same activity twice
|
||||||
minTime := account.Tx.LastUpdate.Add(time.Second * 1)
|
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 {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -37,10 +37,10 @@ func GetActivityForAccount(account string, filterTypes []string, minTime *time.T
|
||||||
params["min_time"] = strings.Join(filterTypes, ",")
|
params["min_time"] = strings.Join(filterTypes, ",")
|
||||||
}
|
}
|
||||||
if minTime != nil {
|
if minTime != nil {
|
||||||
params["min_time"] = minTime.UTC().Format(timeFormat)
|
params["min_time"] = minTime.UTC().Format(time.RFC3339)
|
||||||
}
|
}
|
||||||
if maxTime != nil {
|
if maxTime != nil {
|
||||||
params["max_time"] = maxTime.UTC().Format(timeFormat)
|
params["max_time"] = maxTime.UTC().Format(time.RFC3339)
|
||||||
}
|
}
|
||||||
|
|
||||||
// query the api
|
// query the api
|
||||||
|
@ -88,10 +88,10 @@ func GetRewardTotalsForAccount(account string, minTime *time.Time, maxTime *time
|
||||||
path := "/v1/accounts/" + account + "/rewards/sum"
|
path := "/v1/accounts/" + account + "/rewards/sum"
|
||||||
params := map[string]string{}
|
params := map[string]string{}
|
||||||
if minTime != nil {
|
if minTime != nil {
|
||||||
params["min_time"] = minTime.UTC().Format(timeFormat)
|
params["min_time"] = minTime.UTC().Format(time.RFC3339)
|
||||||
}
|
}
|
||||||
if maxTime != nil {
|
if maxTime != nil {
|
||||||
params["max_time"] = maxTime.UTC().Format(timeFormat)
|
params["max_time"] = maxTime.UTC().Format(time.RFC3339)
|
||||||
}
|
}
|
||||||
|
|
||||||
// query the api
|
// query the api
|
||||||
|
|
|
@ -12,7 +12,7 @@ func GetHeight(maxTime *time.Time) (int, error) {
|
||||||
path := "/v1/blocks/height"
|
path := "/v1/blocks/height"
|
||||||
params := map[string]string{}
|
params := map[string]string{}
|
||||||
if maxTime != nil {
|
if maxTime != nil {
|
||||||
params["max_time"] = maxTime.UTC().Format(timeFormat)
|
params["max_time"] = maxTime.UTC().Format(time.RFC3339)
|
||||||
}
|
}
|
||||||
|
|
||||||
// query the api
|
// query the api
|
||||||
|
|
|
@ -31,10 +31,10 @@ func GetRewardsTotalForHotspot(hotspot string, minTime *time.Time, maxTime *time
|
||||||
path := "/v1/hotspots/" + hotspot + "/rewards/sum"
|
path := "/v1/hotspots/" + hotspot + "/rewards/sum"
|
||||||
params := map[string]string{}
|
params := map[string]string{}
|
||||||
if minTime != nil {
|
if minTime != nil {
|
||||||
params["min_time"] = minTime.UTC().Format(timeFormat)
|
params["min_time"] = minTime.UTC().Format(time.RFC3339)
|
||||||
}
|
}
|
||||||
if maxTime != nil {
|
if maxTime != nil {
|
||||||
params["max_time"] = maxTime.UTC().Format(timeFormat)
|
params["max_time"] = maxTime.UTC().Format(time.RFC3339)
|
||||||
}
|
}
|
||||||
|
|
||||||
// query the api
|
// query the api
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
package heliumapi
|
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 {
|
type AccountResp struct {
|
||||||
Data Account `json:"data"`
|
Data Account `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue