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.TokenManager
import allin.utils.kronJob import allin.utils.kronJob
import com.typesafe.config.ConfigFactory import com.typesafe.config.ConfigFactory
import io.ktor.serialization.kotlinx.json.*
import io.ktor.server.application.* import io.ktor.server.application.*
import io.ktor.server.auth.* import io.ktor.server.auth.*
import io.ktor.server.auth.jwt.* import io.ktor.server.auth.jwt.*
@ -14,7 +15,6 @@ import io.ktor.server.config.*
import io.ktor.server.engine.* import io.ktor.server.engine.*
import io.ktor.server.netty.* import io.ktor.server.netty.*
import io.ktor.server.plugins.contentnegotiation.* import io.ktor.server.plugins.contentnegotiation.*
import kotlinx.serialization.json.Json
import java.time.ZonedDateTime import java.time.ZonedDateTime
import kotlin.time.ExperimentalTime import kotlin.time.ExperimentalTime
import kotlin.time.minutes import kotlin.time.minutes
@ -33,13 +33,6 @@ val Application.dataSource: AllInDataSource
get() = allInDataSource get() = allInDataSource
val json by lazy {
Json {
ignoreUnknownKeys = true
encodeDefaults = true
}
}
fun main() { fun main() {
embeddedServer(Netty, port = 8080, host = "0.0.0.0") { embeddedServer(Netty, port = 8080, host = "0.0.0.0") {
extracted() extracted()
@ -62,7 +55,7 @@ private fun Application.extracted() {
} }
} }
install(ContentNegotiation) { install(ContentNegotiation) {
json json()
} }
BasicRouting() BasicRouting()

@ -29,8 +29,8 @@ class MockBetDataSource : BetDataSource {
override fun updateBetStatuses(date: ZonedDateTime) { override fun updateBetStatuses(date: ZonedDateTime) {
bets.forEachIndexed { idx, bet -> bets.forEachIndexed { idx, bet ->
if (bet.endRegistration >= date) { if (date >= bet.endRegistration) {
if (bet.endBet >= date) { if (date >= bet.endBet) {
bets[idx] = bet.copy(status = BetStatus.WAITING) bets[idx] = bet.copy(status = BetStatus.WAITING)
} else { } else {
bets[idx] = bet.copy(status = BetStatus.CLOSING) bets[idx] = bet.copy(status = BetStatus.CLOSING)

@ -97,16 +97,16 @@ class PostgresBetDataSource(private val database: Database) : BetDataSource {
database.update(BetsEntity) { database.update(BetsEntity) {
set(BetsEntity.status, BetStatus.WAITING) set(BetsEntity.status, BetStatus.WAITING)
where { where {
(BetsEntity.endRegistration greaterEq date.toInstant()) and (date.toInstant() greaterEq BetsEntity.endRegistration) and
(BetsEntity.endBet less date.toInstant()) (date.toInstant() less BetsEntity.endBet)
} }
} }
database.update(BetsEntity) { database.update(BetsEntity) {
set(BetsEntity.status, BetStatus.CLOSING) set(BetsEntity.status, BetStatus.CLOSING)
where { where {
(BetsEntity.endRegistration greaterEq date.toInstant()) and (date.toInstant() greaterEq BetsEntity.endRegistration) and
(BetsEntity.endBet greaterEq date.toInstant()) (date.toInstant() greaterEq BetsEntity.endBet)
} }
} }
} }

Loading…
Cancel
Save