mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 08:46:15 +00:00
Expanded --stats
to contain information about api_levels of messages in the db.
This commit is contained in:
parent
6b44a6c569
commit
1a72ab8735
@ -218,15 +218,24 @@ public class CommandLineController {
|
||||
}
|
||||
|
||||
private void cmd_stats() {
|
||||
HashMap<String, Integer> map = new HashMap<String, Integer>();
|
||||
map.put("count.accounts", Utils.getAccounts().size());
|
||||
map.put("count.messages", Database.getInstance().getMessageCount());
|
||||
map.put("messages.top_id", Database.getInstance().getTopMessageID());
|
||||
System.out.println();
|
||||
System.out.println("Stats:");
|
||||
String format = "%40s: %d%n";
|
||||
System.out.format(format, "Number of accounts", Utils.getAccounts().size());
|
||||
System.out.format(format, "Number of messages", Database.getInstance().getMessageCount());
|
||||
System.out.format(format, "Top message ID", Database.getInstance().getTopMessageID());
|
||||
|
||||
System.out.println();
|
||||
System.out.println("Media Types:");
|
||||
for(Map.Entry<String, Integer> pair : Database.getInstance().getMessageMediaTypesWithCount().entrySet()) {
|
||||
map.put(pair.getKey(), pair.getValue());
|
||||
System.out.format(format, pair.getKey(), pair.getValue());
|
||||
}
|
||||
|
||||
System.out.println(map.toString());
|
||||
System.out.println();
|
||||
System.out.println("Api layers of messages:");
|
||||
for(Map.Entry<String, Integer> pair : Database.getInstance().getMessageApiLayerWithCount().entrySet()) {
|
||||
System.out.format(format, pair.getKey(), pair.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void cmd_login(String phone) throws RpcErrorException, IOException {
|
||||
|
@ -458,6 +458,20 @@ public class Database {
|
||||
} catch (Exception e) { throw new RuntimeException(e); }
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getMessageApiLayerWithCount() {
|
||||
HashMap<String, Integer> map = new HashMap<String, Integer>();
|
||||
try {
|
||||
ResultSet rs = stmt.executeQuery("SELECT COUNT(id), api_layer FROM messages GROUP BY api_layer ORDER BY api_layer");
|
||||
while(rs.next()) {
|
||||
Integer layer = rs.getInt(2);
|
||||
if (layer==null) layer=0;
|
||||
map.put("count.messages.api_layer." + layer, rs.getInt(1));
|
||||
}
|
||||
rs.close();
|
||||
return map;
|
||||
} catch (Exception e) { throw new RuntimeException(e); }
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getMessageAuthorsWithCount() {
|
||||
return getMessageAuthorsWithCount(new GlobalChat());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user