aboutsummaryrefslogtreecommitdiff
path: root/juick-core/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-07-11 10:32:18 +0300
committerGravatar Vitaly Takmazov2016-07-11 10:32:18 +0300
commit567e9a870645d527da95d07103dd0fce31f14585 (patch)
treecb2a62efb432f540d7cdff1512af40c35d0d039d /juick-core/src
parentae9494bbca81e493f9a76da0029b113bf359e573 (diff)
api: fix groups_pms
Diffstat (limited to 'juick-core/src')
-rw-r--r--juick-core/src/main/java/com/juick/server/PMQueries.java13
-rw-r--r--juick-core/src/main/java/com/juick/server/UserQueries.java14
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 10de9a69..fa1dd05f 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 1ba0f83b..13a330e5 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 "