mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2025-06-29 11:56:26 +00:00
Merge branch 'master' into feature-json
This commit is contained in:
@ -222,15 +222,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 {
|
||||
|
@ -52,7 +52,7 @@ public class CommandLineRunner {
|
||||
|
||||
PatternLayoutEncoder encoder = new PatternLayoutEncoder();
|
||||
encoder.setContext(rootContext);
|
||||
encoder.setPattern("%d{HH:mm:ss} %-5level %-35.-35(%logger{0}.%method): %message%n");
|
||||
encoder.setPattern("%d{HH:mm:ss.SSS} %-5level %-35.-35(%logger{0}.%method): %message%n");
|
||||
encoder.start();
|
||||
|
||||
ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<ILoggingEvent>();
|
||||
|
@ -482,6 +482,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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user