From 26e4c1c4046914f064046229e927461d93bce534 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 23 Oct 2021 00:55:06 +0300 Subject: getUserBlogWithRecommendations: fix query --- src/main/java/com/juick/service/MessagesServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/juick/service/MessagesServiceImpl.java') diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index b14e9261..b6a2edb7 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -704,15 +704,15 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ + " AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = messages.user_id) " + " AND NOT EXISTS (SELECT 1 FROM bl_tags bt WHERE bt.tag_id IN " + "(SELECT tag_id FROM messages_tags WHERE message_id = favorites.message_id) and :vid = bt.user_id)" - + (before > 0 ? " AND message_id < :before " : StringUtils.EMPTY) - + " ORDER BY message_id DESC LIMIT 20) as r" + " UNION ALL " + "SELECT message_id FROM " + + (before > 0 ? " AND messages.message_id < :before " : StringUtils.EMPTY) + + " ORDER BY messages.message_id DESC LIMIT 20) as r" + " UNION ALL " + "SELECT message_id FROM " + "(SELECT message_id FROM messages" + " INNER JOIN users" + " ON messages.user_id = users.id" + " WHERE user_id = :uid AND users.banned = 0" + " AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = messages.user_id) " + " AND NOT EXISTS (SELECT 1 FROM bl_tags bt WHERE bt.tag_id IN " + "(SELECT tag_id FROM messages_tags WHERE message_id = messages.message_id) and :vid = bt.user_id)" - + (before > 0 ? " AND message_id < :before" : StringUtils.EMPTY) - + " AND privacy >= :privacy ORDER BY message_id DESC LIMIT 20) as m " + + (before > 0 ? " AND messages.message_id < :before" : StringUtils.EMPTY) + + " AND privacy >= :privacy ORDER BY messages.message_id DESC LIMIT 20) as m " + "ORDER BY message_id DESC LIMIT 20", sqlParameterSource, Integer.class); } -- cgit v1.2.3