aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/server')
-rw-r--r--src/main/java/com/juick/server/PMQueries.java24
1 files changed, 2 insertions, 22 deletions
diff --git a/src/main/java/com/juick/server/PMQueries.java b/src/main/java/com/juick/server/PMQueries.java
index 772a1c28..74d5df3e 100644
--- a/src/main/java/com/juick/server/PMQueries.java
+++ b/src/main/java/com/juick/server/PMQueries.java
@@ -69,33 +69,13 @@ 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=? AND unread>0 "
- + "ORDER BY lastmessage DESC LIMIT " + cnt, (rs, rowNum) -> {
+ + "WHERE 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);
return u;
}, uid);
-
- if (qusers.size() < cnt) {
- List<User> addUsers = sql.query("SELECT user_id,user_id_to "
- + "FROM pm_streams WHERE (user_id=? OR user_id_to=?) "
- + "AND lastmessage>TIMESTAMPADD(MONTH,-1,NOW()) "
- + "ORDER BY lastmessage DESC LIMIT ?", (rs, num) -> {
- User u = new com.juick.User();
- int uuid = rs.getInt(1) + rs.getInt(2) - uid;
- u.setUID(uuid);
- return u;
- }, uid, uid, cnt * 2);
- for (User addUser : addUsers) {
- if (!haveUserInArray(qusers, addUser.getUID())) {
- qusers.add(addUser);
- if (qusers.size() >= cnt) {
- break;
- }
- }
- }
- }
if (!qusers.isEmpty()) {
UserQueries.fillUsersByID(sql, qusers);
}