mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-22 16:56:16 +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() {
|
private void cmd_stats() {
|
||||||
HashMap<String, Integer> map = new HashMap<String, Integer>();
|
System.out.println();
|
||||||
map.put("count.accounts", Utils.getAccounts().size());
|
System.out.println("Stats:");
|
||||||
map.put("count.messages", Database.getInstance().getMessageCount());
|
String format = "%40s: %d%n";
|
||||||
map.put("messages.top_id", Database.getInstance().getTopMessageID());
|
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()) {
|
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 {
|
private void cmd_login(String phone) throws RpcErrorException, IOException {
|
||||||
|
@ -458,6 +458,20 @@ public class Database {
|
|||||||
} catch (Exception e) { throw new RuntimeException(e); }
|
} 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() {
|
public HashMap<String, Object> getMessageAuthorsWithCount() {
|
||||||
return getMessageAuthorsWithCount(new GlobalChat());
|
return getMessageAuthorsWithCount(new GlobalChat());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user