cloud_functions: Added totalsOnly param to notional-tvl-cumulitive
Consumers may only care about the totals which results in a drastically smaller response payload size.
This commit is contained in:
parent
b8b90e1de4
commit
0eb4fb9aae
|
@ -225,10 +225,12 @@ func TvlCumulative(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
|
|
||||||
var numDays string
|
var numDays string
|
||||||
|
var totalsOnly string
|
||||||
switch r.Method {
|
switch r.Method {
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
queryParams := r.URL.Query()
|
queryParams := r.URL.Query()
|
||||||
numDays = queryParams.Get("numDays")
|
numDays = queryParams.Get("numDays")
|
||||||
|
totalsOnly = queryParams.Get("totalsOnly")
|
||||||
}
|
}
|
||||||
|
|
||||||
var queryDays int
|
var queryDays int
|
||||||
|
@ -295,6 +297,8 @@ func TvlCumulative(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
asset.Notional = roundToTwoDecimalPlaces(notional)
|
asset.Notional = roundToTwoDecimalPlaces(notional)
|
||||||
|
|
||||||
|
if totalsOnly == "" {
|
||||||
// create a new LockAsset in order to exclude TokenPrice and Amount
|
// create a new LockAsset in order to exclude TokenPrice and Amount
|
||||||
dailyTvl[date][chain][symbol] = LockedAsset{
|
dailyTvl[date][chain][symbol] = LockedAsset{
|
||||||
Symbol: asset.Symbol,
|
Symbol: asset.Symbol,
|
||||||
|
@ -302,6 +306,7 @@ func TvlCumulative(w http.ResponseWriter, r *http.Request) {
|
||||||
CoinGeckoId: asset.CoinGeckoId,
|
CoinGeckoId: asset.CoinGeckoId,
|
||||||
Notional: asset.Notional,
|
Notional: asset.Notional,
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// add this asset's notional to the date/chain/*
|
// add this asset's notional to the date/chain/*
|
||||||
if allAssets, ok := dailyTvl[date][chain]["*"]; ok {
|
if allAssets, ok := dailyTvl[date][chain]["*"]; ok {
|
||||||
|
|
Loading…
Reference in New Issue