From 0781e23874b8cd9515a183f51dca549b92a4bd6d Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 10 Jul 2021 10:10:10 +0100 Subject: [PATCH] Add update links to each master index Flenarn provided a spreadsheet mapping our master indexes to the corresponding update. Signed-off-by: Graham --- .../openrs2/archive/cache/CacheExporter.kt | 21 ++++++++++++++++++- .../archive/migrations/V4__updates.sql | 7 +++++++ .../archive/templates/caches/show.html | 9 ++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 archive/src/main/resources/org/openrs2/archive/migrations/V4__updates.sql 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 d05be3cb50..a145e8b3de 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/cache/CacheExporter.kt @@ -98,6 +98,7 @@ public class CacheExporter @Inject constructor( public data class Cache( val id: Int, val sources: List, + val updates: List, val stats: Stats?, val masterIndex: Js5MasterIndex ) @@ -284,7 +285,25 @@ public class CacheExporter @Inject constructor( } } - Cache(id, sources, stats, masterIndex) + val updates = mutableListOf() + + connection.prepareStatement( + """ + SELECT url + FROM updates + WHERE master_index_id = ? + """.trimIndent() + ).use { stmt -> + stmt.setInt(1, id) + + stmt.executeQuery().use { rows -> + while (rows.next()) { + updates += rows.getString(1) + } + } + } + + Cache(id, sources, updates, stats, masterIndex) } } diff --git a/archive/src/main/resources/org/openrs2/archive/migrations/V4__updates.sql b/archive/src/main/resources/org/openrs2/archive/migrations/V4__updates.sql new file mode 100644 index 0000000000..2b0bf7dfb1 --- /dev/null +++ b/archive/src/main/resources/org/openrs2/archive/migrations/V4__updates.sql @@ -0,0 +1,7 @@ +-- @formatter:off +CREATE TABLE updates ( + master_index_id INTEGER NOT NULL REFERENCES master_indexes (id), + url TEXT NOT NULL, + PRIMARY KEY (master_index_id, url) +); +-- @formatter:on 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 index d771fcf191..2a616469ea 100644 --- a/archive/src/main/resources/org/openrs2/archive/templates/caches/show.html +++ b/archive/src/main/resources/org/openrs2/archive/templates/caches/show.html @@ -69,6 +69,15 @@ + + Update(s) + + + https://www.example.com/ +
+
+ +

Sources