mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 08:46:15 +00:00
Extended --stats to also show the different source_types from the database.
This commit is contained in:
parent
c83de2ed00
commit
28931830eb
@ -231,6 +231,11 @@ class CommandLineController {
|
||||
for ((key, value) in Database.getInstance().getMessageApiLayerWithCount()) {
|
||||
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)
|
||||
|
@ -125,6 +125,21 @@ class Database private constructor(var client: TelegramClient) {
|
||||
fun getMessageTypesWithCount(): HashMap<String, Int> = getMessageTypesWithCount(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> {
|
||||
val map = HashMap<String, Int>()
|
||||
|
Loading…
Reference in New Issue
Block a user