diff --git a/db/statistics.go b/db/statistics.go index 0aa85a0b52..e0c202fe6c 100644 --- a/db/statistics.go +++ b/db/statistics.go @@ -1309,8 +1309,9 @@ func GetValidatorIncomeHistory(validatorIndices []uint64, lowerBoundDay uint64, } result = append(result, types.ValidatorIncomeHistory{ - Day: int64(currentDay), - ClRewards: int64(totalBalance - lastBalance - lastDeposits + lastWithdrawals), + Day: int64(currentDay), + ClRewards: int64(totalBalance - lastBalance - lastDeposits + lastWithdrawals), + EndBalance: sql.NullInt64{Int64: int64(totalBalance), Valid: true}, // show the latest balance for todays income }) } diff --git a/services/rewards.go b/services/rewards.go index ba4f153965..2250d2da88 100644 --- a/services/rewards.go +++ b/services/rewards.go @@ -29,6 +29,10 @@ func GetValidatorHist(validatorArr []uint64, currency string, start uint64, end var pricesDb []types.Price // we get prices with a 1 day buffer to so we have no problems in different time zones var oneDay = uint64(24 * 60 * 60) + + if start == end { // no date range was provided, use the current day as ending boundary + end = uint64(time.Now().Unix()) + } err = db.WriterDb.Select(&pricesDb, `select ts, eur, usd, gbp, cad, jpy, cny, rub, aud from price where ts >= TO_TIMESTAMP($1) and ts <= TO_TIMESTAMP($2) order by ts desc`, start-oneDay, end+oneDay) if err != nil {