Add percentages to the keys page

Signed-off-by: Graham <gpe@openrs2.org>
bzip2
Graham 4 years ago
parent 6c728d758c
commit 593f46d9fd
  1. 13
      archive/src/main/kotlin/org/openrs2/archive/key/KeyExporter.kt
  2. 6
      archive/src/main/resources/org/openrs2/archive/templates/keys/index.html

@ -14,7 +14,18 @@ public class KeyExporter @Inject constructor(
val validKeys: Long, val validKeys: Long,
val encryptedGroups: Long, val encryptedGroups: Long,
val validGroups: 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 { public suspend fun count(): Stats {
return database.execute { connection -> return database.execute { connection ->

@ -16,14 +16,16 @@
There are There are
<strong th:text="${#numbers.formatInteger(stats.allKeys, 1, 'COMMA')}">0</strong> <strong th:text="${#numbers.formatInteger(stats.allKeys, 1, 'COMMA')}">0</strong>
candidate keys in the database, of which candidate keys in the database, of which
<strong th:text="${#numbers.formatInteger(stats.validKeys, 1, 'COMMA')}">0</strong> <strong
th:text="${#numbers.formatInteger(stats.validKeys, 1, 'COMMA')} + ' (' + ${#numbers.formatPercent(stats.validKeysFraction, 1, 2)} + ')'">0</strong>
have been validated against at least one encrypted group. have been validated against at least one encrypted group.
</p> </p>
<p> <p>
There are There are
<strong th:text="${#numbers.formatInteger(stats.encryptedGroups, 1, 'COMMA')}">0</strong> <strong th:text="${#numbers.formatInteger(stats.encryptedGroups, 1, 'COMMA')}">0</strong>
encrypted groups in the database, of which encrypted groups in the database, of which
<strong th:text="${#numbers.formatInteger(stats.validGroups, 1, 'COMMA')}">0</strong> <strong
th:text="${#numbers.formatInteger(stats.validGroups, 1, 'COMMA')} + ' (' + ${#numbers.formatPercent(stats.validGroupsFraction, 1, 2)} + ')'">0</strong>
have a validated key. This is equal to the total number of have a validated key. This is equal to the total number of
validated keys if and only if keys are not re-used. validated keys if and only if keys are not re-used.
</p> </p>

Loading…
Cancel
Save