From dc56b67ff617a44ade9ff340bc52be49f03d4257 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 10 Nov 2025 14:18:13 +0100 Subject: [PATCH] Sort fights by start time in descending order and refactor `saveFromStream` method to use `useDb` block. Signed-off-by: Chaoscaot --- CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt b/CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt index adb25b90..62de6038 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt @@ -25,6 +25,7 @@ import org.jetbrains.exposed.v1.core.dao.id.IdTable import org.jetbrains.exposed.v1.core.eq import org.jetbrains.exposed.v1.dao.IntEntity import org.jetbrains.exposed.v1.dao.IntEntityClass +import org.jetbrains.exposed.v1.javatime.CurrentTimestamp import org.jetbrains.exposed.v1.javatime.timestamp import java.security.MessageDigest import java.sql.Timestamp @@ -33,7 +34,7 @@ import java.time.Instant object NodeDownloadTable: IdTable("NodeDownload") { override val id = reference("NodeId", SchematicNodeTable).uniqueIndex() val link = varchar("Link", 255) - val timestamp = timestamp("Timestamp").default(Instant.now()) + val timestamp = timestamp("Timestamp").defaultExpression(CurrentTimestamp) } class NodeDownload(id: EntityID) : IntEntity(id) { @@ -49,7 +50,9 @@ class NodeDownload(id: EntityID) : IntEntity(id) { digest.update("${Instant.now()}${schem.owner}${schem.nodeId}".toByteArray()) val hash = digest.digest().joinToString("") { "%02x".format(it) } useDb { - new { + findByIdAndUpdate(schem.id.value) { + it.link = hash + } ?: new { nodeId = schem.id.value link = hash }