1
0
mirror of https://github.com/fabianonline/telegram_backup.git synced 2024-11-22 08:46:15 +00:00

Fixed stats in the HTML export for channels.

This commit is contained in:
Fabian Schlenz 2017-12-02 15:05:04 +01:00
parent 99574c6e6e
commit fff3483e63

View File

@ -497,11 +497,21 @@ public class Database {
HashMap<String, Object> map = new HashMap<String, Object>(); HashMap<String, Object> map = new HashMap<String, Object>();
HashMap<User, Integer> user_map = new HashMap<User, Integer>(); HashMap<User, Integer> user_map = new HashMap<User, Integer>();
int count_others = 0; int count_others = 0;
// Set a default value for 'me' to fix the charts for channels - cause I
// possibly didn't send any messages there.
map.put("authors.count.me", 0);
try { try {
ResultSet rs = stmt.executeQuery("SELECT users.id, users.first_name, users.last_name, users.username, COUNT(messages.id) "+ ResultSet rs = stmt.executeQuery("SELECT users.id, users.first_name, users.last_name, users.username, COUNT(messages.id) "+
"FROM messages, users WHERE users.id=messages.sender_id AND " + c.getQuery() + " GROUP BY sender_id"); "FROM messages " +
"LEFT JOIN users ON users.id=messages.sender_id " +
"WHERE " + c.getQuery() + " GROUP BY sender_id");
while (rs.next()) { while (rs.next()) {
User u = new User(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4)); User u;
if (rs.getString(2)!=null || rs.getString(3)!=null || rs.getString(4)!=null) {
u = new User(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4));
} else {
u = new User(rs.getInt(1), "Unknown", "", "");
}
if (u.isMe) { if (u.isMe) {
map.put("authors.count.me", rs.getInt(5)); map.put("authors.count.me", rs.getInt(5));
} else { } else {