diff options
author | Vitaly Takmazov | 2021-10-25 01:24:37 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2021-10-25 01:24:37 +0300 |
commit | 2cbaa2dd212bb81d34e7b52eff4d03e4780d02de (patch) | |
tree | 8b9da98161e4b2ec3d042233f08bbd219bd7a7d4 /src/main/java/com/juick/service/MessagesServiceImpl.java | |
parent | 1bca4586c8358ce7cef302c6019f112100b34393 (diff) |
Fix top candidates query and update tests
Diffstat (limited to 'src/main/java/com/juick/service/MessagesServiceImpl.java')
-rw-r--r-- | src/main/java/com/juick/service/MessagesServiceImpl.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index eb953586..3bb58a17 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -969,11 +969,11 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ public List<Integer> getPopularCandidates() { return getJdbcTemplate().queryForList("SELECT replies.message_id FROM replies " + "INNER JOIN messages ON replies.message_id = messages.message_id " - + "INNER JOIN favorites ON favorites.message_id = messages.message_id " + + "LEFT JOIN favorites ON favorites.message_id = messages.message_id " + "LEFT JOIN messages_tags ON messages_tags.message_id = messages.message_id " + "WHERE COALESCE(messages_tags.tag_id, 0) != 2 " + "AND COALESCE(messages_tags.tag_id, 0) != 805 AND replies.ts > TIMESTAMPADD(HOUR, -2, CURRENT_TIMESTAMP) " - + "AND favorites.user_id != 2 GROUP BY messages.message_id having COUNT(DISTINCT(replies.user_id)) > 5 " + + "AND COALESCE(favorites.user_id, 0) != 2 GROUP BY messages.message_id having COUNT(DISTINCT(replies.user_id)) > 5 " + "UNION ALL SELECT favorites.message_id FROM favorites " + "INNER JOIN messages ON messages.message_id = favorites.message_id " + "LEFT JOIN messages_tags ON messages_tags.message_id = messages.message_id " |