From 593f46d9fdcf838afe59d29acff422b1ec015804 Mon Sep 17 00:00:00 2001
From: Graham
Date: Sat, 3 Apr 2021 10:20:14 +0100
Subject: [PATCH] Add percentages to the keys page
Signed-off-by: Graham
---
.../kotlin/org/openrs2/archive/key/KeyExporter.kt | 13 ++++++++++++-
.../org/openrs2/archive/templates/keys/index.html | 6 ++++--
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt b/archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt
index 56f235f6e6..f41b0d6538 100644
--- a/archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt
+++ b/archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt
@@ -14,7 +14,18 @@ public class KeyExporter @Inject constructor(
val validKeys: Long,
val encryptedGroups: Long,
val validGroups: Long
- )
+ ) {
+ val validKeysFraction: Double = if (allKeys == 0L) {
+ 1.0
+ } else {
+ validKeys.toDouble() / allKeys
+ }
+ val validGroupsFraction: Double = if (encryptedGroups == 0L) {
+ 1.0
+ } else {
+ validGroups.toDouble() / encryptedGroups
+ }
+ }
public suspend fun count(): Stats {
return database.execute { connection ->
diff --git a/archive/src/main/resources/org/openrs2/archive/templates/keys/index.html b/archive/src/main/resources/org/openrs2/archive/templates/keys/index.html
index 9edf2aea94..7ebf7017bd 100644
--- a/archive/src/main/resources/org/openrs2/archive/templates/keys/index.html
+++ b/archive/src/main/resources/org/openrs2/archive/templates/keys/index.html
@@ -16,14 +16,16 @@
There are
0
candidate keys in the database, of which
- 0
+ 0
have been validated against at least one encrypted group.
There are
0
encrypted groups in the database, of which
- 0
+ 0
have a validated key. This is equal to the total number of
validated keys if and only if keys are not re-used.