From d71ce6095b87958d2df4da27b1344ad0e5b77a44 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 3 Feb 2023 01:32:17 +0300 Subject: top_ignore_tags -> tags.notop --- src/main/java/com/juick/service/MessagesServiceImpl.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 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 3ddfcd00..eb1acd59 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -1044,27 +1044,26 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ @Override public List getPopularCandidates() { var beforeTime = Instant.now().minus(2, ChronoUnit.HOURS); - var nsfw = tagService.getTag("NSFW", true); var sql = """ SELECT replies.message_id FROM replies INNER JOIN messages ON replies.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) != :nsfw_id AND replies.ts > :before + LEFT JOIN tags ON messages_tags.tag_id=tags.tag_id + WHERE COALESCE(tags.notop, 0)=0 AND replies.ts > :before AND NOT EXISTS (SELECT 1 FROM favorites WHERE message_id = messages.message_id AND user_id = 2) GROUP BY replies.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 + LEFT JOIN tags ON messages_tags.tag_id=tags.tag_id + WHERE COALESCE(tags.notop, 0)=0 AND favorites.ts > :before AND NOT EXISTS (SELECT 1 FROM favorites WHERE message_id = messages.message_id AND user_id = 2) GROUP BY favorites.message_id HAVING COUNT(DISTINCT favorites.user_id) > 2 """; return getNamedParameterJdbcTemplate().queryForList(sql, new MapSqlParameterSource() - .addValue("nsfw_id", nsfw.getId()) .addValue("before", toDateTime(beforeTime.atOffset(ZoneOffset.UTC)), dateTimeType()), Integer.class); -- cgit v1.2.3