diff options
Diffstat (limited to 'juick-core/src')
-rw-r--r-- | juick-core/src/main/java/com/juick/server/PMQueries.java | 13 | ||||
-rw-r--r-- | juick-core/src/main/java/com/juick/server/UserQueries.java | 14 |
2 files changed, 5 insertions, 22 deletions
diff --git a/juick-core/src/main/java/com/juick/server/PMQueries.java b/juick-core/src/main/java/com/juick/server/PMQueries.java index 10de9a693..fa1dd05f4 100644 --- a/juick-core/src/main/java/com/juick/server/PMQueries.java +++ b/juick-core/src/main/java/com/juick/server/PMQueries.java @@ -68,19 +68,16 @@ public class PMQueries { } public static List<User> getPMLastConversationsUsers(JdbcTemplate sql, int uid, int cnt) { - List<User> qusers = sql.query("SELECT user_id,unread FROM pm_streams " - + "WHERE user_id_to=? " + return sql.query("SELECT pm_streams.user_id, users.nick, pm_streams.unread FROM pm_streams " + + "INNER JOIN users ON users.id = pm_streams.user_id" + + "WHERE pm_streams.user_id_to=? " + "ORDER BY unread DESC, lastmessage DESC LIMIT " + cnt, (rs, rowNum) -> { com.juick.User u = new com.juick.User(); u.setUID(rs.getInt(1)); - u.MessagesCount = rs.getInt(2); + u.setUName(rs.getString(2)); + u.MessagesCount = rs.getInt(3); return u; }, uid); - if (!qusers.isEmpty()) { - UserQueries.fillUsersByID(sql, qusers); - } - - return qusers; } public static List<com.juick.Message> getPMMessages(JdbcTemplate sql, int uid, int uid_to) { diff --git a/juick-core/src/main/java/com/juick/server/UserQueries.java b/juick-core/src/main/java/com/juick/server/UserQueries.java index 1ba0f83b0..13a330e56 100644 --- a/juick-core/src/main/java/com/juick/server/UserQueries.java +++ b/juick-core/src/main/java/com/juick/server/UserQueries.java @@ -133,20 +133,6 @@ public class UserQueries { return Collections.emptyList(); } - public static boolean fillUsersByID(JdbcTemplate sql, List<User> users) { - String uids = StringUtils.arrayToCommaDelimitedString(users.stream().map(u -> u.getUID()).collect(Collectors.toList()).toArray()); - - sql.query("SELECT id,nick,banned FROM users WHERE id IN (" + uids + ")", - (rs, num) -> { - User u = new User(); - u.setUID(rs.getInt(1)); - u.setUName(rs.getString(2)); - return u; - }); - - return true; - } - public static List<com.juick.User> getUsersByJID(JdbcTemplate sql, List<String> jids) { if (!jids.isEmpty()) { return sql.query("SELECT users.id,users.nick,jids.jid FROM users " |