hotfix for query chain-activity (#1543)

This commit is contained in:
Mariano 2024-07-11 15:52:29 -03:00 committed by GitHub
parent 752f6117f5
commit cdb56f0740
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 32 additions and 0 deletions

View File

@ -383,6 +383,38 @@ func (r *Repository) buildChainActivityQuery(q *ChainActivityQuery) string {
} else {
field = "count"
}
if q.TimeSpan == ChainActivityTs1Year || q.TimeSpan == ChainActivityTsAllTime {
if field == "notional" {
field = "volume"
}
var start string
measurement := "chain_activity_1d"
switch q.TimeSpan {
case ChainActivityTs1Year:
start = time.Now().AddDate(-1, 0, 0).Format(time.RFC3339)
case ChainActivityTsAllTime:
start = "1970-01-01T00:00:00Z"
default:
start = "1970-01-01T00:00:00Z"
}
hotfixQuery := `
import "date"
from(bucket: "%s")
|> range(start: %s)
|> filter(fn: (r) => r._measurement == "%s")
|> filter(fn: (r) => r._field == "%s")
|> drop(columns:["_time","to","_measurement"])
|> sum()
`
return fmt.Sprintf(hotfixQuery, r.bucketInfiniteRetention, start, measurement, field)
}
var measurement string
switch q.TimeSpan {
case ChainActivityTs7Days: