Revert "Add EventCache for efficient retrieval of event groups and teams"

This reverts commit 8b4f864f99.

Revert "Refactor EventFights and Fight classes to improve player initialization and retrieval"

This reverts commit 8d705e7a84.

Revert "Refactor EventFights and Fight classes to improve player initialization and retrieval"

This reverts commit 78352a3e67.
This commit is contained in:
2025-11-14 23:24:48 +01:00
parent 78352a3e67
commit f923a007a7
6 changed files with 12 additions and 93 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ class Fight(id: EntityID<Int>) : IntEntity(id) {
lateinit var bluePlayers: List<FightPlayer>
lateinit var redPlayers: List<FightPlayer>
fun initPlayers(fightPlayers: List<FightPlayer>) {
private fun initPlayers(fightPlayers: List<FightPlayer>) {
val blue = mutableListOf<FightPlayer>()
val red = mutableListOf<FightPlayer>()
@@ -23,7 +23,6 @@ import de.steamwar.sql.internal.useDb
import org.jetbrains.exposed.v1.core.dao.id.CompositeID
import org.jetbrains.exposed.v1.core.dao.id.CompositeIdTable
import org.jetbrains.exposed.v1.core.dao.id.EntityID
import org.jetbrains.exposed.v1.core.eq
import org.jetbrains.exposed.v1.core.inList
import org.jetbrains.exposed.v1.dao.CompositeEntity
import org.jetbrains.exposed.v1.dao.CompositeEntityClass
@@ -68,11 +67,6 @@ class FightPlayer(id: EntityID<CompositeID>) : CompositeEntity(id) {
fun batchGet(fightIds: List<Int>) = useDb {
find { FightPlayerTable.fightId inList fightIds.toList() }.toList()
}
@JvmStatic
fun getFight(fightId: Int) = useDb {
find { FightPlayerTable.fightId eq fightId }.toList()
}
}
val fightID by FightPlayerTable.fightId.transform({ EntityID(it, FightTable) }, { it.value })
+2 -2
View File
@@ -43,10 +43,10 @@ class Team(id: EntityID<Int>) : IntEntity(id) {
private val teamCache = mutableMapOf<Int, Team>()
@JvmStatic
fun clear() = synchronized(teamCache) { teamCache.clear() }
fun clear() = teamCache.clear()
@JvmStatic
fun byId(id: Int) = synchronized(teamCache) { teamCache.computeIfAbsent(id) { useDb { Team[id] } } }
fun byId(id: Int) = teamCache.computeIfAbsent(id) { useDb { Team[id] } }
@JvmStatic
fun get(name: String) = useDb { find { TeamTable.name.lowerCase() eq name.lowercase() or (TeamTable.kuerzel.lowerCase() eq name.lowercase()) }.firstOrNull() }