diff options
author | Vitaly Takmazov | 2023-02-13 14:10:06 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-02-13 14:14:26 +0300 |
commit | 82cea834e7caf54561ec1efe05b0f9c36ffdffc5 (patch) | |
tree | a72d08324506ca0c6b6647264e7d44fb3c2eec52 | |
parent | 1e9779588c5595af410bfeaa981946fa3c2cef32 (diff) |
Code cleanup
-rw-r--r-- | src/main/java/com/juick/service/MessagesServiceImpl.java | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index 8a0f9ecf..b0e365f8 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -790,35 +790,15 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ OR EXISTS (SELECT 1 from users u WHERE u.banned = 1 and u.id = replies.user_id and u.id <> :uid)) UNION ALL SELECT replies.message_id, replies.reply_id FROM replies INNER JOIN banned ON banned.reply_id = replies.replyto AND replies.reply_id != replies.replyto AND banned.message_id=replies.message_id - WHERE replies.message_id IN (:ids)) - SELECT messages.message_id, - 0 as rid, - 0 as replyto, - messages.user_id, - users.nick, - users.banned as usr_banned, - messages.ts, - messages.readonly, - messages.privacy, - 1.*messages.replies-COUNT(DISTINCT banned.reply_id) as replies, - messages.attach, - COUNT(DISTINCT favorites.user_id) AS likes, - messages.hidden, - '' as tags, - messages.repliesby, - COALESCE(messages.txt, '') txt, '' as q, - messages.updated, - 0 as to_uid, - NULL as to_name, - messages.updated_at, - '' as m_user_uri, - '' as to_uri, - '' as msg_reply_uri, - 0 as html, + WHERE replies.message_id IN (:ids)) SELECT messages.message_id, 0 as rid, 0 as replyto, messages.user_id, + users.nick, users.banned as usr_banned, messages.ts, messages.readonly, messages.privacy, + 1.*messages.replies-COUNT(DISTINCT banned.reply_id) as replies, messages.attach, + COUNT(DISTINCT favorites.user_id) AS likes, messages.hidden, '' as tags, messages.repliesby, + COALESCE(messages.txt, '') txt, '' as q, messages.updated, 0 as to_uid, NULL as to_name, + messages.updated_at, '' as m_user_uri, '' as to_uri, '' as msg_reply_uri, 0 as html, (1.*messages.replies - subscr_messages.last_read_rid) as unread, (SELECT CASE WHEN EXISTS(SELECT * from subscr_messages where message_id=messages.message_id and suser_id=:uid) THEN 1 ELSE 0 END) subscribed - FROM messages - INNER JOIN users ON messages.user_id=users.id LEFT JOIN subscr_messages + FROM messages INNER JOIN users ON messages.user_id=users.id LEFT JOIN subscr_messages ON messages.message_id=subscr_messages.message_id AND subscr_messages.suser_id=:uid LEFT JOIN favorites ON messages.message_id = favorites.message_id AND favorites.like_id=1 LEFT JOIN banned ON messages.message_id = banned.message_id |