diff --git a/src/main/java/de/fabianonline/telegram_backup/Database.java b/src/main/java/de/fabianonline/telegram_backup/Database.java index 7d7d609..e32a050 100644 --- a/src/main/java/de/fabianonline/telegram_backup/Database.java +++ b/src/main/java/de/fabianonline/telegram_backup/Database.java @@ -430,25 +430,31 @@ public class Database { public HashMap getMessageMediaTypesWithCount() { HashMap map = new HashMap(); try { + int count = 0; ResultSet rs = stmt.executeQuery("SELECT media_type, COUNT(id) FROM messages GROUP BY media_type"); while (rs.next()) { String s = rs.getString(1); - if (s==null) s="null"; + if (s==null) { + s="null"; + } else { + count += rs.getInt(2); + } map.put(s, rs.getInt(2)); } + map.put("any", count); return map; } catch (Exception e) { throw new RuntimeException(e); } } public int[][] getMessageTimesMatrix(Integer dialog_id, Integer chat_id) { - int result[][] = new int[24][7]; + int result[][] = new int[7][24]; try { - ResultSet rs = stmt.executeQuery("SELECT STRFTIME('%H', time, 'unixepoch') AS hour, " + - "STRFTIME('%w', time, 'unixepoch') as DAY, " + + ResultSet rs = stmt.executeQuery("SELECT STRFTIME('%w', time, 'unixepoch') as DAY, " + + "STRFTIME('%H', time, 'unixepoch') AS hour, " + "COUNT(id) FROM messages GROUP BY hour, day " + "ORDER BY hour, day"); while (rs.next()) { - result[rs.getInt(1)][rs.getInt(2) == 0 ? 6 : rs.getInt(2)-1] = rs.getInt(3); + result[rs.getInt(1) == 0 ? 6 : rs.getInt(1)-1][rs.getInt(2)] = rs.getInt(3); } return result; } catch (Exception e) { throw new RuntimeException(e); } diff --git a/src/main/java/de/fabianonline/telegram_backup/exporter/HTMLExporter.java b/src/main/java/de/fabianonline/telegram_backup/exporter/HTMLExporter.java index 411fb46..d854abb 100644 --- a/src/main/java/de/fabianonline/telegram_backup/exporter/HTMLExporter.java +++ b/src/main/java/de/fabianonline/telegram_backup/exporter/HTMLExporter.java @@ -118,13 +118,10 @@ public class HTMLExporter { StringBuilder sb = new StringBuilder(); sb.append("["); for (int x=0; x0) sb.append(", "); - sb.append("["); for (int y=0; y0) sb.append(", "); - sb.append(data[x][y]); + if (x>0 || y>0) sb.append(","); + sb.append("[" + x + "," + y + "," + data[x][y] + "]"); } - sb.append("]"); } sb.append("]"); return sb.toString(); diff --git a/src/main/resources/templates/html/index.mustache b/src/main/resources/templates/html/index.mustache index eb25c77..3d8eecb 100644 --- a/src/main/resources/templates/html/index.mustache +++ b/src/main/resources/templates/html/index.mustache @@ -3,59 +3,109 @@ Telegram Backup for {{user.getUserString}} - - + + + + + @@ -88,35 +138,11 @@ {{/chats}} - - + -
-
-
+ + +