Fix FightStatistics

Signed-off-by: Chaoscaot <max@maxsp.de>
This commit is contained in:
2025-11-30 17:27:27 +01:00
parent 624fe98c47
commit 0fd7aab86c
2 changed files with 3 additions and 3 deletions
@@ -90,7 +90,7 @@ class EventGroup(id: EntityID<Int>) : IntEntity(id) {
set(value) {
groupPointsPerDraw = value
}
val dependents by lazy { EventRelation.getGroupRelations(this) }
val dependents by lazy { EventRelation.getGroupRelations(this).toList() }
val lastFight by lazy { Optional.ofNullable(fights.maxByOrNull { it.startTime }) }
fun getId() = id.value
@@ -117,10 +117,10 @@ class EventRelation(id: EntityID<Int>) : IntEntity(id) {
fromPlace = place
}
fun getAdvancingTeam(): Team? = when(fromType) {
fun getAdvancingTeam(): Team? = useDb { when(fromType) {
FromType.FIGHT -> if (fromPlace == 0) fromFight?.winner else fromFight?.losser
FromType.GROUP -> fromGroup?.calculatePoints()?.toList()?.sortedBy { (_, v) -> v }?.reversed()?.elementAt(fromPlace)?.first
}
} }
fun apply(): Boolean {
val team = getAdvancingTeam() ?: return false