From 2a2e941dfe8bb8b64f4f7cb5581fda364850b755 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Sun, 21 Jan 2024 12:29:18 +0100 Subject: [PATCH] fixing sorting Signed-off-by: Stephan Richter --- src/main/java/de/srsoftware/widerhall/data/Post.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/srsoftware/widerhall/data/Post.java b/src/main/java/de/srsoftware/widerhall/data/Post.java index 92b062f..b9b897a 100644 --- a/src/main/java/de/srsoftware/widerhall/data/Post.java +++ b/src/main/java/de/srsoftware/widerhall/data/Post.java @@ -18,6 +18,7 @@ import java.sql.Timestamp; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; +import java.util.TreeMap; import static de.srsoftware.widerhall.Constants.*; import static de.srsoftware.widerhall.Constants.VARCHAR; @@ -173,9 +174,9 @@ public class Post { return this; } - public static HashMap summarize(MailingList list) throws SQLException { + public static Map summarize(MailingList list) throws SQLException { var sql = new StringBuilder("SELECT count(*) as count,strftime('%Y-%m',date/1000,'unixepoch') as month FROM Posts WHERE list = ? GROUP BY month ORDER BY month;"); - var map = new HashMap(); + var map = new TreeMap(); var rs = Database.open().query(sql).compile(list.email()).exec(); while (rs.next()) map.put(rs.getString("month"),rs.getInt("count")); rs.close();