Patch BetDetail when it has 0 participation
continuous-integration/drone/push Build is passing Details

master
luevard 8 months ago
parent 36c186d359
commit a395c753dc

@ -58,20 +58,25 @@ interface BetEntity : Entity<BetEntity> {
.filter { it.betId eq bet.id } .filter { it.betId eq bet.id }
.map { it.toBetAnswerInfo() } .map { it.toBetAnswerInfo() }
return BetDetail( val betD = BetDetail(
bet = bet, bet = bet,
answers = getBetAnswerDetail(bet, participationEntities, answerInfos), answers = getBetAnswerDetail(bet, participationEntities, answerInfos),
participations = participationEntities, participations = participationEntities,
userParticipation = userParticipation?.toParticipation(database), userParticipation = userParticipation?.toParticipation(database),
wonParticipation = if (bet.status == BetStatus.FINISHED) { wonParticipation = if (participationEntities.isEmpty()) {
val result = database.betResults.find { it.betId eq this.id } null
result?.let { r -> } else if (bet.status == BetStatus.FINISHED) {
database.betResults.find { it.betId eq this.id }?.let { r ->
participationEntities participationEntities
.filter { it.answer == r.result } .filter { it.answer == r.result }
.maxBy { it.stake } .maxBy { it.stake }
} }
} else null } else null
) )
return betD
} }
} }

Loading…
Cancel
Save