aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-02-03 01:32:17 +0300
committerGravatar Vitaly Takmazov2023-02-03 03:39:43 +0300
commitd71ce6095b87958d2df4da27b1344ad0e5b77a44 (patch)
tree1f7cccba70151c86e94620ccc583a5801b273563 /src/main/java/com/juick/service
parent17aa96df5776812e2b2fb212b071a821685c9598 (diff)
top_ignore_tags -> tags.notop
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);