pull/8/head
Arthur VALIN 1 year ago
parent 07042b5379
commit be81c92571

@ -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()

@ -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)

@ -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)
}
}
}

Loading…
Cancel
Save