Merge branch 'master' into getParticipationInformation
continuous-integration/drone/pr Build is failing Details
continuous-integration/drone/push Build is passing Details

pull/17/head
Lucas EVARD 1 year ago
commit b5dffc403d

@ -197,12 +197,27 @@ class PostgresBetDataSource(private val database: Database) : BetDataSource {
}
)
if (bet.type == BetType.CUSTOM) {
bet.response.forEach { selected ->
val responses = if (bet.type == BetType.BINARY) {
listOf(YES_VALUE, NO_VALUE)
} else {
bet.response
}
responses.forEach { response ->
database.betAnswerInfos.add(
BetAnswerInfoEntity {
this.betId = bet.id
this.response = response
this.totalStakes = 0
this.odds = 1f
}
)
if (bet.type == BetType.CUSTOM) {
database.responses.add(
ResponseEntity {
this.betId = bet.id
this.response = selected
this.response = response
}
)
}

@ -34,8 +34,9 @@ class PostgresParticipationDataSource(private val database: Database) : Particip
if (it.response == participation.answer) {
it.totalStakes += participation.stake
}
val probability = it.totalStakes / betInfo.totalStakes.toFloat()
it.odds = 1 / probability
val probability = (it.totalStakes / betInfo.totalStakes.toFloat())
it.odds = if (probability == 0f) 1f else 1 / probability
it.flushChanges()
}
}

Loading…
Cancel
Save