1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-11-23 01:06:17 +00:00

Extended --stats to also show the different source_types from the database.

This commit is contained in:
Fabian Schlenz 2017-12-17 11:39:07 +01:00
parent c83de2ed00
commit 28931830eb
2 changed files with 20 additions and 0 deletions

View File

@ -231,6 +231,11 @@ class CommandLineController {
for ((key, value) in Database.getInstance().getMessageApiLayerWithCount()) { for ((key, value) in Database.getInstance().getMessageApiLayerWithCount()) {
System.out.format(format, key, value) System.out.format(format, key, value)
} }
println()
println("Message source types:")
for ((key, value) in Database.getInstance().getMessageSourceTypeWithCount()) {
System.out.format(format, key, value)
}
} }
@Throws(RpcErrorException::class, IOException::class) @Throws(RpcErrorException::class, IOException::class)

View File

@ -126,6 +126,21 @@ class Database private constructor(var client: TelegramClient) {
fun getMessageMediaTypesWithCount(): HashMap<String, Int> = getMessageMediaTypesWithCount(GlobalChat()) fun getMessageMediaTypesWithCount(): HashMap<String, Int> = getMessageMediaTypesWithCount(GlobalChat())
fun getMessageSourceTypeWithCount(): HashMap<String, Int> {
val map = HashMap<String, Int>()
try {
val rs = stmt!!.executeQuery("SELECT COUNT(id), source_type FROM messages GROUP BY source_type ORDER BY source_type")
while (rs.next()) {
val source_type = rs.getString(2) ?: "null"
map.put("count.messages.source_type.${source_type}", rs.getInt(1))
}
rs.close()
return map
} catch (e:Exception) {
throw RuntimeException(e)
}
}
fun getMessageApiLayerWithCount(): HashMap<String, Int> { fun getMessageApiLayerWithCount(): HashMap<String, Int> {
val map = HashMap<String, Int>() val map = HashMap<String, Int>()
try { try {