@ -15,30 +15,40 @@ public class KeyExporter @Inject constructor(
val allKeys : Long ,
val allKeys : Long ,
val validKeys : Long ,
val validKeys : Long ,
val encryptedGroups : Long ,
val encryptedGroups : Long ,
val validGroups : Long
val validGroups : Long ,
val emptyGroups : Long
) {
) {
val validKeysFraction : Double = if ( allKeys == 0L ) {
val validKeysFraction : Double = if ( allKeys == 0L ) {
1.0
1.0
} else {
} else {
validKeys . toDouble ( ) / allKeys
validKeys . toDouble ( ) / allKeys
}
}
val validGroupsFraction : Double = if ( encryptedGroups == 0L ) {
val validGroupsFraction : Double = if ( encryptedGroups == 0L ) {
1.0
1.0
} else {
} else {
validGroups . toDouble ( ) / encryptedGroups
validGroups . toDouble ( ) / encryptedGroups
}
}
val emptyGroupsFraction : Double = if ( encryptedGroups == 0L ) {
1.0
} else {
emptyGroups . toDouble ( ) / encryptedGroups
}
}
}
public suspend fun count ( ) : Stats {
public suspend fun count ( ) : Stats {
return database . execute { connection ->
return database . execute { connection ->
val encryptedGroups : Long
val encryptedGroups : Long
val validGroups : Long
val validGroups : Long
val emptyGroups : Long
connection . prepareStatement (
connection . prepareStatement (
"""
"""
SELECT
SELECT
COUNT ( * ) ,
COUNT ( * ) ,
COUNT ( * ) FILTER ( WHERE c . key _id IS NOT NULL )
COUNT ( * ) FILTER ( WHERE c . key _id IS NOT NULL ) ,
COUNT ( * ) FILTER ( WHERE c . key _id IS NULL AND c . empty _loc )
FROM containers c
FROM containers c
WHERE c . encrypted
WHERE c . encrypted
""" .trimIndent()
""" .trimIndent()
@ -48,6 +58,7 @@ public class KeyExporter @Inject constructor(
encryptedGroups = rows . getLong ( 1 )
encryptedGroups = rows . getLong ( 1 )
validGroups = rows . getLong ( 2 )
validGroups = rows . getLong ( 2 )
emptyGroups = rows . getLong ( 3 )
}
}
}
}
@ -65,7 +76,7 @@ public class KeyExporter @Inject constructor(
val allKeys = rows . getLong ( 1 )
val allKeys = rows . getLong ( 1 )
val validKeys = rows . getLong ( 2 )
val validKeys = rows . getLong ( 2 )
Stats ( allKeys , validKeys , encryptedGroups , validGroups )
Stats ( allKeys , validKeys , encryptedGroups , validGroups , emptyGroups )
}
}
}
}
}
}