Skip to content

Commit

Permalink
Merge pull request #2805 from gobitfly/BIDS-2914/fix_reward_details_view
Browse files Browse the repository at this point in the history
(BIDS-2914) fix balance for current day + currency conversion
  • Loading branch information
recy21 authored Feb 8, 2024
2 parents d8389ee + 4b103fc commit a02a49c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions db/statistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}

Expand Down
4 changes: 4 additions & 0 deletions services/rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a02a49c

Please sign in to comment.