diff --git a/Sources/src/main/kotlin/allin/Application.kt b/Sources/src/main/kotlin/allin/Application.kt index ce9d498..34f4187 100644 --- a/Sources/src/main/kotlin/allin/Application.kt +++ b/Sources/src/main/kotlin/allin/Application.kt @@ -7,6 +7,7 @@ import allin.routing.* import allin.utils.TokenManager import allin.utils.kronJob import com.typesafe.config.ConfigFactory +import io.ktor.serialization.kotlinx.json.* import io.ktor.server.application.* import io.ktor.server.auth.* import io.ktor.server.auth.jwt.* @@ -14,7 +15,6 @@ import io.ktor.server.config.* import io.ktor.server.engine.* import io.ktor.server.netty.* import io.ktor.server.plugins.contentnegotiation.* -import kotlinx.serialization.json.Json import java.time.ZonedDateTime import kotlin.time.ExperimentalTime import kotlin.time.minutes @@ -33,13 +33,6 @@ val Application.dataSource: AllInDataSource get() = allInDataSource -val json by lazy { - Json { - ignoreUnknownKeys = true - encodeDefaults = true - } -} - fun main() { embeddedServer(Netty, port = 8080, host = "0.0.0.0") { extracted() @@ -62,7 +55,7 @@ private fun Application.extracted() { } } install(ContentNegotiation) { - json + json() } BasicRouting() diff --git a/Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt b/Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt index 3d8c780..a2d04a0 100644 --- a/Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt +++ b/Sources/src/main/kotlin/allin/data/mock/MockBetDataSource.kt @@ -29,8 +29,8 @@ class MockBetDataSource : BetDataSource { override fun updateBetStatuses(date: ZonedDateTime) { bets.forEachIndexed { idx, bet -> - if (bet.endRegistration >= date) { - if (bet.endBet >= date) { + if (date >= bet.endRegistration) { + if (date >= bet.endBet) { bets[idx] = bet.copy(status = BetStatus.WAITING) } else { bets[idx] = bet.copy(status = BetStatus.CLOSING) diff --git a/Sources/src/main/kotlin/allin/data/postgres/PostgresBetDataSource.kt b/Sources/src/main/kotlin/allin/data/postgres/PostgresBetDataSource.kt index ffad229..824c5ff 100644 --- a/Sources/src/main/kotlin/allin/data/postgres/PostgresBetDataSource.kt +++ b/Sources/src/main/kotlin/allin/data/postgres/PostgresBetDataSource.kt @@ -97,16 +97,16 @@ class PostgresBetDataSource(private val database: Database) : BetDataSource { database.update(BetsEntity) { set(BetsEntity.status, BetStatus.WAITING) where { - (BetsEntity.endRegistration greaterEq date.toInstant()) and - (BetsEntity.endBet less date.toInstant()) + (date.toInstant() greaterEq BetsEntity.endRegistration) and + (date.toInstant() less BetsEntity.endBet) } } database.update(BetsEntity) { set(BetsEntity.status, BetStatus.CLOSING) where { - (BetsEntity.endRegistration greaterEq date.toInstant()) and - (BetsEntity.endBet greaterEq date.toInstant()) + (date.toInstant() greaterEq BetsEntity.endRegistration) and + (date.toInstant() greaterEq BetsEntity.endBet) } } }