diff options
Diffstat (limited to 'juick-server-jdbc')
-rw-r--r-- | juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java | 48 | ||||
-rw-r--r-- | juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java | 10 |
2 files changed, 25 insertions, 33 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java index b6a37883..6c12583c 100644 --- a/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/juick-server-jdbc/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -73,27 +73,25 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ user.setName(rs.getString(5)); user.setBanned(rs.getBoolean(6)); msg.setUser(user); - msg.TimeAgo = rs.getInt(7); - msg.setTimestamp(rs.getTimestamp(8).toInstant()); - msg.ReadOnly = rs.getBoolean(9); - msg.setPrivacy(rs.getInt(10)); + msg.setTimestamp(rs.getTimestamp(7).toInstant()); + msg.ReadOnly = rs.getBoolean(8); + msg.setPrivacy(rs.getInt(9)); msg.FriendsOnly = msg.getPrivacy() < 0; - msg.setReplies(rs.getInt(11)); - msg.setAttachmentType(rs.getString(12)); - // TODO: reorder after place deletion - msg.setLikes(rs.getInt(16)); - msg.Hidden = rs.getBoolean(17); - String tagsStr = rs.getString(18); + msg.setReplies(rs.getInt(10)); + msg.setAttachmentType(rs.getString(11)); + msg.setLikes(rs.getInt(12)); + msg.Hidden = rs.getBoolean(13); + String tagsStr = rs.getString(14); msg.setTags(MessageUtils.parseTags(tagsStr)); - msg.setRepliesBy(rs.getString(19)); - msg.setText(rs.getString(20)); - msg.setReplyQuote(MessageUtils.formatQuote(rs.getString(21))); - msg.setUpdated(rs.getTimestamp(22).toInstant()); - int quoteUid = rs.getInt(23); + msg.setRepliesBy(rs.getString(15)); + msg.setText(rs.getString(16)); + msg.setReplyQuote(MessageUtils.formatQuote(rs.getString(17))); + msg.setUpdated(rs.getTimestamp(18).toInstant()); + int quoteUid = rs.getInt(19); if (quoteUid > 0) { User quoteUser = new User(); quoteUser.setUid(quoteUid); - quoteUser.setName(rs.getString(24)); + quoteUser.setName(rs.getString(20)); msg.setTo(quoteUser); } try { @@ -326,11 +324,10 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ List<com.juick.Message> list = getJdbcTemplate().query( "SELECT messages.message_id as mid, 0 as rid, 0 as replyto, " + "messages.user_id as uid, users.nick, users.banned as banned, " - + "TIMESTAMPDIFF(MINUTE, messages.ts, NOW()) as ago," + + "" + "messages.ts," + "messages.readonly, messages.privacy, messages.replies," - + "messages.attach, messages.place_id, messages.lat," - + "messages.lon, COUNT(DISTINCT favorites.user_id) as likes, messages.hidden," + + "messages.attach, COUNT(DISTINCT favorites.user_id) as likes, messages.hidden," + "txt.tags, txt.repliesby, txt.txt, '' as q, messages.updated, 0 as to_uid, " + "NULL as to_name FROM messages " + "INNER JOIN users ON messages.user_id = users.id " @@ -339,8 +336,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ + "LEFT JOIN favorites " + "ON messages.message_id = favorites.message_id AND favorites.like_id=1 " + "WHERE messages.message_id = ? " - + "GROUP BY mid, rid, replyto, uid, nick, banned, ago, messages.ts, readonly, " - + "privacy, replies, attach, place_id, lat, lon, tags, repliesby, q", + + "GROUP BY mid, rid, replyto, uid, nick, banned, messages.ts, readonly, " + + "privacy, replies, attach, tags, repliesby, q", new MessageMapper(), mid); if (!list.isEmpty()) { @@ -779,11 +776,9 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ List<com.juick.Message> msgs = getNamedParameterJdbcTemplate().query( "SELECT messages.message_id, 0 as rid, 0 as replyto, " + "messages.user_id,users.nick, 0 as banned, " - + "TIMESTAMPDIFF(MINUTE,messages.ts,NOW())," + "messages.ts," + "messages.readonly,messages.privacy,messages.replies," - + "messages.attach,messages.place_id,messages.lat," - + "messages.lon,COUNT(DISTINCT favorites.user_id) AS likes,messages.hidden," + + "messages.attach,COUNT(DISTINCT favorites.user_id) AS likes,messages.hidden," + "messages_txt.tags,messages_txt.repliesby, messages_txt.txt, '' as q, " + "messages.updated, 0 as to_uid, NULL as to_name " + "FROM (messages INNER JOIN messages_txt " @@ -844,10 +839,9 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ List<Message> replies = getNamedParameterJdbcTemplate().query( "SELECT replies.message_id as mid, replies.reply_id, replies.replyto, " + "replies.user_id, users.nick, users.banned, " + - "TIMESTAMPDIFF(MINUTE, replies.ts, NOW()), replies.ts, " + + "replies.ts, " + "0 as readonly, 0 as privacy, 0 as replies, " + - "replies.attach, 0 as place_id, 0 as lat, " + - "0 as lon, 0 as likes, 0 as hidden, " + + "replies.attach, 0 as likes, 0 as hidden, " + "NULL as tags, NULL as repliesby, replies.txt, " + "IFNULL(qw.txt, t.txt) as q, " + "NOW(), " + diff --git a/juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java index d42e375c..67d7b386 100644 --- a/juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java +++ b/juick-server-jdbc/src/main/java/com/juick/service/PMQueriesServiceImpl.java @@ -135,7 +135,7 @@ public class PMQueriesServiceImpl extends BaseJdbcService implements PMQueriesSe @Override public List<com.juick.Message> getLastPMInbox(final int uid) { return getJdbcTemplate().query( - "SELECT pm.user_id,users.nick,pm.txt,TIMESTAMPDIFF(MINUTE,pm.ts,NOW()),pm.ts " + + "SELECT pm.user_id, users.nick, pm.txt, pm.ts " + "FROM pm INNER JOIN users ON pm.user_id=users.id WHERE pm.user_id_to=? ORDER BY pm.ts DESC LIMIT 20", (rs, num) -> { com.juick.Message msg = new com.juick.Message(); @@ -143,8 +143,7 @@ public class PMQueriesServiceImpl extends BaseJdbcService implements PMQueriesSe msg.getUser().setUid(rs.getInt(1)); msg.getUser().setName(rs.getString(2)); msg.setText(rs.getString(3)); - msg.TimeAgo = rs.getInt(4); - msg.setTimestamp(rs.getTimestamp(5).toInstant()); + msg.setTimestamp(rs.getTimestamp(4).toInstant()); return msg; }, uid); @@ -154,7 +153,7 @@ public class PMQueriesServiceImpl extends BaseJdbcService implements PMQueriesSe @Override public List<com.juick.Message> getLastPMSent(final int uid) { return getJdbcTemplate().query( - "SELECT pm.user_id_to,users.nick,pm.txt,TIMESTAMPDIFF(MINUTE,pm.ts,NOW())," + + "SELECT pm.user_id_to, users.nick, pm.txt, " + "pm.ts FROM pm INNER JOIN users ON pm.user_id_to=users.id " + "WHERE pm.user_id=? ORDER BY pm.ts DESC LIMIT 20", (rs, num) -> { @@ -163,8 +162,7 @@ public class PMQueriesServiceImpl extends BaseJdbcService implements PMQueriesSe msg.getUser().setUid(rs.getInt(1)); msg.getUser().setName(rs.getString(2)); msg.setText(rs.getString(3)); - msg.TimeAgo = rs.getInt(4); - msg.setTimestamp(rs.getTimestamp(5).toInstant()); + msg.setTimestamp(rs.getTimestamp(4).toInstant()); return msg; }, uid); |