Format CacheExporter

Signed-off-by: Graham <gpe@openrs2.org>
master
Graham 3 years ago
parent 1a78ef3c7d
commit 5c77ee4bd2
  1. 12
      archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt

@ -375,7 +375,8 @@ public class CacheExporter @Inject constructor(
public suspend fun getFileName(id: Int): String? { public suspend fun getFileName(id: Int): String? {
return database.execute { connection -> return database.execute { connection ->
// TODO(gpe): what if a cache is from multiple games? // TODO(gpe): what if a cache is from multiple games?
connection.prepareStatement(""" connection.prepareStatement(
"""
SELECT SELECT
g.name AS game, g.name AS game,
e.name AS environment, e.name AS environment,
@ -390,7 +391,8 @@ public class CacheExporter @Inject constructor(
WHERE s.cache_id = ? WHERE s.cache_id = ?
GROUP BY g.name, e.name, l.iso_code GROUP BY g.name, e.name, l.iso_code
LIMIT 1 LIMIT 1
""".trimIndent()).use { stmt -> """.trimIndent()
).use { stmt ->
stmt.setInt(1, id) stmt.setInt(1, id)
stmt.executeQuery().use { rows -> stmt.executeQuery().use { rows ->
@ -413,9 +415,11 @@ public class CacheExporter @Inject constructor(
val timestamp = rows.getTimestamp(5) val timestamp = rows.getTimestamp(5)
if (!rows.wasNull()) { if (!rows.wasNull()) {
name.append('-') name.append('-')
name.append(timestamp.toInstant() name.append(
timestamp.toInstant()
.atOffset(ZoneOffset.UTC) .atOffset(ZoneOffset.UTC)
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss"))) .format(DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm-ss"))
)
} }
name.append("-openrs2#") name.append("-openrs2#")

Loading…
Cancel
Save