From 0dd1017e81c133c6307384ef8ad381e4d57974f5 Mon Sep 17 00:00:00 2001 From: "arthur.valin" Date: Wed, 7 Feb 2024 22:17:10 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20toConfirm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/allin/data/mock/MockBetDataSource.kt | 12 +++++++----- .../allin/data/postgres/PostgresBetDataSource.kt | 4 +++- Sources/src/main/kotlin/allin/routing/BetRouter.kt | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt b/Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt index ca8e046..f7eb3ad 100644 --- a/Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt +++ b/Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt @@ -33,11 +33,13 @@ class MockBetDataSource(mockData: MockDataSource.MockData) : BetDataSource { override fun updateBetStatuses(date: ZonedDateTime) { bets.forEachIndexed { idx, bet -> - if (date >= bet.endRegistration) { - if (date >= bet.endBet) { - bets[idx] = bet.copy(status = WAITING) - } else { - bets[idx] = bet.copy(status = CLOSING) + if (bet.status != CANCELLED && bet.status != FINISHED) { + if (date >= bet.endRegistration) { + if (date >= bet.endBet) { + bets[idx] = bet.copy(status = WAITING) + } else { + bets[idx] = bet.copy(status = CLOSING) + } } } } diff --git a/Sources/src/main/kotlin/allin/data/postgres/PostgresBetDataSource.kt b/Sources/src/main/kotlin/allin/data/postgres/PostgresBetDataSource.kt index 5bc55f0..fbfba37 100644 --- a/Sources/src/main/kotlin/allin/data/postgres/PostgresBetDataSource.kt +++ b/Sources/src/main/kotlin/allin/data/postgres/PostgresBetDataSource.kt @@ -204,7 +204,9 @@ class PostgresBetDataSource(private val database: Database) : BetDataSource { set(BetsEntity.status, BetStatus.WAITING) where { (date.toInstant() greaterEq BetsEntity.endRegistration) and - (date.toInstant() less BetsEntity.endBet) + (date.toInstant() less BetsEntity.endBet) and + (BetsEntity.status notEq BetStatus.FINISHED) and + (BetsEntity.status notEq BetStatus.CANCELLED) } } diff --git a/Sources/src/main/kotlin/allin/routing/BetRouter.kt b/Sources/src/main/kotlin/allin/routing/BetRouter.kt index f0b70ed..16d8f01 100644 --- a/Sources/src/main/kotlin/allin/routing/BetRouter.kt +++ b/Sources/src/main/kotlin/allin/routing/BetRouter.kt @@ -92,8 +92,8 @@ fun Application.BetRouter() { BetDetail( it, getBetAnswerDetail(it, participations), - participations.toList(), - participationDataSource.getParticipationFromUserId(user.username, it.id).lastOrNull() + participations, + participations.find { it.username == user.username } ) } call.respond(HttpStatusCode.Accepted, response)