aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java9
1 files changed, 4 insertions, 5 deletions
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);