Sort fights by start time in descending order and refactor saveFromStream method to use useDb block.

Signed-off-by: Chaoscaot <max@maxsp.de>
This commit is contained in:
2025-11-10 12:24:51 +01:00
parent 990a03ca6c
commit 7e5a13989b
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -22,6 +22,7 @@ package de.steamwar.sql
import de.steamwar.sql.internal.useDb
import org.jetbrains.exposed.v1.core.IntegerColumnType
import org.jetbrains.exposed.v1.core.ReferenceOption
import org.jetbrains.exposed.v1.core.SortOrder
import org.jetbrains.exposed.v1.core.dao.id.EntityID
import org.jetbrains.exposed.v1.core.dao.id.IntIdTable
import org.jetbrains.exposed.v1.core.eq
@@ -80,7 +81,7 @@ class Fight(id: EntityID<Int>) : IntEntity(id) {
@JvmStatic
fun getPage(page: Int, pageSize: Int): List<Fight> = useDb {
val fights = all().limit(pageSize).offset((pageSize * page).toLong())
val fights = all().orderBy(FightTable.startTime to SortOrder.DESC).limit(pageSize).offset((pageSize * page).toLong())
val fightPlayer = FightPlayer.batchGet(fights.map { it.id.value })
for (fight in fights) {
@@ -74,7 +74,7 @@ class NodeData(id: EntityID<CompositeID>): CompositeEntity(id) {
}
@JvmStatic
fun saveFromStream(node: SchematicNode, blob: InputStream, format: SchematicFormat) {
fun saveFromStream(node: SchematicNode, blob: InputStream, format: SchematicFormat) = useDb {
NodeDataTable.insertIgnore {
it[NodeDataTable.nodeId] = EntityID(node.getId(), SchematicNodeTable)
it[NodeDataTable.nodeFormat] = format