diff options
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/juick/TopManager.java | 19 | ||||
-rw-r--r-- | src/main/java/com/juick/service/MessagesServiceImpl.java | 9 |
2 files changed, 13 insertions, 15 deletions
diff --git a/src/main/java/com/juick/TopManager.java b/src/main/java/com/juick/TopManager.java index d7917fbc..13e91b34 100644 --- a/src/main/java/com/juick/TopManager.java +++ b/src/main/java/com/juick/TopManager.java @@ -17,22 +17,21 @@ package com.juick; -import com.juick.model.CommandResult; -import com.juick.model.Message; -import com.juick.model.Tag; -import com.juick.model.User; -import com.juick.service.MessagesService; +import java.net.URI; +import java.util.List; + +import javax.inject.Inject; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Scheduled; -import javax.inject.Inject; - -import java.net.URI; -import java.util.List; -import java.util.stream.Collectors; +import com.juick.model.CommandResult; +import com.juick.model.Message; +import com.juick.model.Tag; +import com.juick.model.User; +import com.juick.service.MessagesService; public class TopManager { private static final Logger logger = LoggerFactory.getLogger(TopManager.class); 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<Integer> 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); |