aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-07-01 12:27:19 +0300
committerGravatar Vitaly Takmazov2016-07-01 12:27:19 +0300
commit53a4aaacf585e70aadd3b1133319a5bb1e08f0c4 (patch)
tree835b6b91a0a78b06fdc9d1dbc37a5881c4c8023e /src/main/java
parent797942249b0d5e38285e806bc0e73e755e6ffede (diff)
fix pm conversations query
Diffstat (limited to 'src/main/java')
-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);
}