diff --git a/api/handlers/transactions/repository.go b/api/handlers/transactions/repository.go index 740a7031..79e7d892 100644 --- a/api/handlers/transactions/repository.go +++ b/api/handlers/transactions/repository.go @@ -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: