diff --git a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt
index fec8cfde..d570225c 100644
--- a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt
+++ b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt
@@ -48,6 +48,7 @@ public class CacheExporter @Inject constructor(
val build: Int?,
val timestamp: Instant?,
val name: String?,
+ val description: String?,
val archiveStats: ArchiveStats?,
val groupStats: GroupStats?
)
@@ -109,7 +110,7 @@ public class CacheExporter @Inject constructor(
null
}
- caches += Cache(id, game, build, timestamp, name, archiveStats, groupStats)
+ caches += Cache(id, game, build, timestamp, name, description = null, archiveStats, groupStats)
}
caches
@@ -118,6 +119,63 @@ public class CacheExporter @Inject constructor(
}
}
+ public suspend fun get(id: Int): Cache? {
+ return database.execute { connection ->
+ connection.prepareStatement(
+ """
+ SELECT
+ g.name, m.build, m.timestamp, m.name, m.description,
+ a.indexes, a.valid_indexes, gs.groups, gs.valid_groups, gs.keys, gs.valid_keys
+ FROM master_indexes m
+ JOIN games g ON g.id = m.game_id
+ JOIN containers c ON c.id = m.container_id
+ LEFT JOIN master_index_archive_stats a ON a.master_index_id = m.id
+ LEFT JOIN master_index_group_stats gs ON gs.master_index_id = m.id
+ WHERE m.id = ?
+ """.trimIndent()
+ ).use { stmt ->
+ stmt.setInt(1, id)
+
+ stmt.executeQuery().use { rows ->
+ if (!rows.next()) {
+ return@execute null
+ }
+
+ val game = rows.getString(1)
+
+ var build: Int? = rows.getInt(2)
+ if (rows.wasNull()) {
+ build = null
+ }
+
+ val timestamp = rows.getTimestamp(3)?.toInstant()
+ val name = rows.getString(4)
+ val description = rows.getString(5)
+
+ val indexes = rows.getLong(6)
+ val archiveStats = if (!rows.wasNull()) {
+ val validIndexes = rows.getLong(7)
+ ArchiveStats(indexes, validIndexes)
+ } else {
+ null
+ }
+
+ val groups = rows.getLong(8)
+ val groupStats = if (!rows.wasNull()) {
+ val validGroups = rows.getLong(9)
+ val keys = rows.getLong(10)
+ val validKeys = rows.getLong(11)
+ GroupStats(groups, validGroups, keys, validKeys)
+ } else {
+ null
+ }
+
+ return@execute Cache(id, game, build, timestamp, name, description, archiveStats, groupStats)
+ }
+ }
+ }
+ }
+
public suspend fun export(id: Int, store: Store) {
database.execute { connection ->
connection.prepareStatement(
diff --git a/archive/src/main/kotlin/org/openrs2/archive/web/CachesController.kt b/archive/src/main/kotlin/org/openrs2/archive/web/CachesController.kt
index 7e1a7919..33a0c058 100644
--- a/archive/src/main/kotlin/org/openrs2/archive/web/CachesController.kt
+++ b/archive/src/main/kotlin/org/openrs2/archive/web/CachesController.kt
@@ -26,6 +26,22 @@ public class CachesController @Inject constructor(
call.respond(ThymeleafContent("caches/index.html", mapOf("caches" to caches)))
}
+ public suspend fun show(call: ApplicationCall) {
+ val id = call.parameters["id"]?.toIntOrNull()
+ if (id == null) {
+ call.respond(HttpStatusCode.NotFound)
+ return
+ }
+
+ val cache = exporter.get(id)
+ if (cache == null) {
+ call.respond(HttpStatusCode.NotFound)
+ return
+ }
+
+ call.respond(ThymeleafContent("caches/show.html", mapOf("cache" to cache)))
+ }
+
public suspend fun export(call: ApplicationCall) {
val id = call.parameters["id"]?.toIntOrNull()
if (id == null) {
diff --git a/archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt b/archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt
index 33321d80..60f85939 100644
--- a/archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt
+++ b/archive/src/main/kotlin/org/openrs2/archive/web/WebServer.kt
@@ -43,6 +43,7 @@ public class WebServer @Inject constructor(
routing {
get("/caches") { cachesController.index(call) }
+ get("/caches/{id}") { cachesController.show(call) }
get("/caches/{id}.zip") { cachesController.export(call) }
get("/caches/{id}.json") { cachesController.exportKeys(call) }
}
diff --git a/archive/src/main/resources/org/openrs2/archive/templates/caches/index.html b/archive/src/main/resources/org/openrs2/archive/templates/caches/index.html
index 2a5c5d65..bd63ea56 100644
--- a/archive/src/main/resources/org/openrs2/archive/templates/caches/index.html
+++ b/archive/src/main/resources/org/openrs2/archive/templates/caches/index.html
@@ -1,21 +1,13 @@
-
- OpenRS2 Archive
+
+ Caches - OpenRS2 Archive
-
+
+ Caches
@@ -27,7 +19,7 @@
Indexes |
Groups |
Keys1 |
- Download |
+ Links |
@@ -62,6 +54,8 @@
class="btn btn-primary btn-sm">Cache
Keys
+ More
diff --git a/archive/src/main/resources/org/openrs2/archive/templates/caches/show.html b/archive/src/main/resources/org/openrs2/archive/templates/caches/show.html
new file mode 100644
index 00000000..c4c05781
--- /dev/null
+++ b/archive/src/main/resources/org/openrs2/archive/templates/caches/show.html
@@ -0,0 +1,69 @@
+
+
+
+ Cache - OpenRS2 Archive
+
+
+
+
+
+ Cache
+
+
+
+
+ Game |
+ runescape |
+
+
+ Build |
+ 550 |
+
+
+ Timestamp |
+ |
+
+
+ Name |
+ |
+
+
+ Description |
+ |
+
+
+ Indexes |
+
+ Calculating...
+ |
+
+
+ Groups |
+
+ Calculating...
+ |
+
+
+ Keys1 |
+
+ Calculating...
+ |
+
+
+ Download |
+
+
+ |
+
+
+
+
+
diff --git a/archive/src/main/resources/org/openrs2/archive/templates/layout.html b/archive/src/main/resources/org/openrs2/archive/templates/layout.html
new file mode 100644
index 00000000..e6ba6924
--- /dev/null
+++ b/archive/src/main/resources/org/openrs2/archive/templates/layout.html
@@ -0,0 +1,23 @@
+
+
+
+
+ OpenRS2 Archive
+
+
+
+
+
+
+
+