Skip to content

Commit

Permalink
Merge pull request #2455 from fluidity-money/develop-handle-null-sum-…
Browse files Browse the repository at this point in the history
…amounts

Check if the amount is null and return 0 instead
  • Loading branch information
eli-d authored Dec 18, 2023
2 parents 4cdba57 + 3859897 commit 6e6e5fd
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/databases/timescale/spooler/spooler.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,18 @@ func UnpaidWinningsForCategory(network_ network.BlockchainNetwork, token token_d
token.TokenShortName,
)

var total float64
var total sql.NullFloat64

err := row.Scan(&total)

if err == sql.ErrNoRows {
switch err {
case sql.ErrNoRows:
return 0
}

if err != nil {
case nil:
// nothing

default:
log.Fatal(func(k *log.Log) {
k.Context = Context

Expand All @@ -259,7 +262,11 @@ func UnpaidWinningsForCategory(network_ network.BlockchainNetwork, token token_d
})
}

return total
if total.Valid {
return total.Float64
} else {
return 0
}
}

func GetAndRemoveRewardsForCategory(network_ network.BlockchainNetwork, token token_details.TokenDetails) []worker.EthereumReward {
Expand Down

0 comments on commit 6e6e5fd

Please sign in to comment.