aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2021-10-23 22:06:17 +0300
committerGravatar Vitaly Takmazov2021-10-23 22:06:17 +0300
commit1f6514473be20ed134f2fc89315b72b2b8162375 (patch)
treec274ee6101713dc3e85934d074b790e2a7c0d241 /src/main/java
parent7a790cf66d6fe7dc68bcb96c2e80eeae7e7c6e8f (diff)
Update top candidates query
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index a787779b..eb953586 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -969,15 +969,16 @@ 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 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 messages.popular=0 GROUP BY messages.message_id having COUNT(DISTINCT(replies.user_id)) > 5 "
+ + "AND favorites.user_id != 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 "
+ "WHERE COALESCE(messages_tags.tag_id, 0) != 2 AND favorites.ts > TIMESTAMPADD(HOUR, -2, CURRENT_TIMESTAMP) "
- + "AND messages.popular=0 GROUP BY messages.message_id HAVING COUNT(DISTINCT favorites.user_id) > 1;",
+ + "AND favorites.user_id != 2 GROUP BY messages.message_id HAVING COUNT(DISTINCT favorites.user_id) > 1;",
Integer.class);
}