aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/MessagesQueries.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/server/MessagesQueries.java')
-rw-r--r--src/main/java/com/juick/server/MessagesQueries.java21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/main/java/com/juick/server/MessagesQueries.java b/src/main/java/com/juick/server/MessagesQueries.java
index 422cfe7d..c4919a8d 100644
--- a/src/main/java/com/juick/server/MessagesQueries.java
+++ b/src/main/java/com/juick/server/MessagesQueries.java
@@ -349,31 +349,30 @@ public class MessagesQueries {
}
public static List<Integer> getMyFeed(JdbcTemplate sql, int uid, int before) {
- List<Integer> mids = new ArrayList<>(40);
+ List<Integer> mids;
if (before > 0) {
mids = sql.queryForList("SELECT message_id FROM messages " +
"INNER JOIN subscr_users ON (subscr_users.suser_id=? AND subscr_users.user_id=messages.user_id) " +
"WHERE message_id<? AND (privacy>=0 OR (privacy>=-2 AND privacy<=-1 AND messages.user_id " +
"IN (SELECT user_id FROM wl_users WHERE wl_user_id=?))) ORDER BY message_id DESC LIMIT 20",
- Integer.class, new Object[]{uid, before, uid});
+ Integer.class, uid, before, uid);
} else {
mids = sql.queryForList("SELECT message_id FROM messages " +
"INNER JOIN subscr_users ON (subscr_users.suser_id=? " +
"AND subscr_users.user_id=messages.user_id) " +
"WHERE (privacy>=0 OR (privacy>=-2 AND privacy<=-1 AND messages.user_id " +
"IN (SELECT user_id FROM wl_users WHERE wl_user_id=?))) ORDER BY message_id DESC LIMIT 20",
- Integer.class, new Object[]{uid, uid});
+ Integer.class, uid, uid);
}
if (before > 0) {
mids.addAll(sql.queryForList("SELECT message_id FROM messages " +
"WHERE user_id=? AND message_id<? ORDER BY message_id DESC LIMIT 20", Integer.class,
- new Object[]{uid, before}));
+ uid, before));
} else {
mids.addAll(sql.queryForList("SELECT message_id FROM messages " +
- "WHERE user_id=? ORDER BY message_id DESC LIMIT 20", Integer.class,
- new Object[]{uid}));
+ "WHERE user_id=? ORDER BY message_id DESC LIMIT 20", Integer.class, uid));
}
Collections.sort(mids, Collections.reverseOrder());
@@ -399,10 +398,10 @@ public class MessagesQueries {
public static List<Integer> getDiscussions(JdbcTemplate sql, int uid, int before) {
if (before > 0) {
return sql.queryForList("SELECT message_id FROM subscr_messages WHERE suser_id=? AND message_id<? " +
- "ORDER BY message_id DESC LIMIT 20", new Object[]{uid, before}, Integer.class);
+ "ORDER BY message_id DESC LIMIT 20", Integer.class, uid, before);
} else {
return sql.queryForList("SELECT message_id FROM subscr_messages WHERE suser_id=? " +
- "ORDER BY message_id DESC LIMIT 20", new Object[]{uid}, Integer.class);
+ "ORDER BY message_id DESC LIMIT 20", Integer.class, uid);
}
}
@@ -410,11 +409,11 @@ public class MessagesQueries {
if (before > 0) {
return sql.queryForList("SELECT message_id FROM favorites WHERE user_id " +
"IN (SELECT user_id FROM subscr_users WHERE suser_id=?) AND message_id<? " +
- "ORDER BY message_id DESC LIMIT 20", new Object[]{uid, before}, Integer.class);
+ "ORDER BY message_id DESC LIMIT 20", Integer.class, uid, before);
} else {
return sql.queryForList("SELECT message_id FROM favorites WHERE user_id " +
"IN (SELECT user_id FROM subscr_users WHERE suser_id=?) " +
- "ORDER BY message_id DESC LIMIT 20", new Object[]{uid}, Integer.class);
+ "ORDER BY message_id DESC LIMIT 20", Integer.class, uid);
}
}
@@ -422,7 +421,7 @@ public class MessagesQueries {
if (before > 0) {
return sql.queryForList("SELECT message_id FROM messages WHERE message_id<? AND privacy>0 " +
- "AND popular>0 ORDER BY message_id DESC LIMIT 20", new Object[] {before}, Integer.class);
+ "AND popular>0 ORDER BY message_id DESC LIMIT 20", Integer.class, before);
} else {
return sql.queryForList("SELECT message_id FROM messages WHERE privacy>0 " +
"AND popular>0 ORDER BY message_id DESC LIMIT 20", Integer.class);