1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-11-10 19:36:15 +00:00

'--stats' now also counts chats and users in the DB.

This commit is contained in:
Fabian Schlenz 2017-02-26 13:20:36 +01:00
parent be56f21a0f
commit 14d80a70fe
2 changed files with 8 additions and 2 deletions

View File

@ -223,6 +223,8 @@ public class CommandLineController {
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, "Number of chats", Database.getInstance().getChatCount());
System.out.format(format, "Number of users", Database.getInstance().getUserCount());
System.out.format(format, "Top message ID", Database.getInstance().getTopMessageID());
System.out.println();

View File

@ -133,9 +133,9 @@ public class Database {
} catch (SQLException e) {}
}
public int getMessageCount() {
public int queryInt(String query) {
try {
ResultSet rs = stmt.executeQuery("SELECT COUNT(*) FROM messages");
ResultSet rs = stmt.executeQuery(query);
rs.next();
return rs.getInt(1);
} catch (SQLException e) {
@ -143,6 +143,10 @@ public class Database {
}
}
public int getMessageCount() { return queryInt("SELECT COUNT(*) FROM messages"); }
public int getChatCount() { return queryInt("SELECT COUNT(*) FROM chats"); }
public int getUserCount() { return queryInt("SELECT COUNT(*) FROM users"); }
public LinkedList<Integer> getMissingIDs() {
try {
LinkedList<Integer> missing = new LinkedList<Integer>();