From 8f8e3bafdbe22c9beb27afb593bbc5b57512c53d Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 18 Oct 2022 17:23:37 +0300 Subject: Better trends query on `/api/tags` endpoint --- src/main/java/com/juick/service/TagServiceImpl.java | 4 ++-- src/main/java/com/juick/www/api/Tags.java | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/main/java/com/juick/service/TagServiceImpl.java b/src/main/java/com/juick/service/TagServiceImpl.java index a5f3241a..81c0c3ba 100644 --- a/src/main/java/com/juick/service/TagServiceImpl.java +++ b/src/main/java/com/juick/service/TagServiceImpl.java @@ -172,11 +172,11 @@ public class TagServiceImpl extends BaseJdbcService implements TagService { public List getTagStats() { return getJdbcTemplate().query( "SELECT tags.name,COUNT(DISTINCT messages.user_id) AS cnt " + - "FROM (messages INNER JOIN messages_tags ON (messages.ts>TIMESTAMPADD(DAY,-3,NOW()) " + + "FROM (messages INNER JOIN messages_tags ON (messages.ts>TIMESTAMPADD(DAY,-14,NOW()) " + "AND messages.message_id=messages_tags.message_id)) " + "INNER JOIN tags ON messages_tags.tag_id=tags.tag_id " + "WHERE tags.tag_id NOT IN (SELECT tag_id FROM tags_ignore) " + - "GROUP BY tags.tag_id ORDER BY cnt DESC LIMIT 20", new TagStatsMapper()); + "GROUP BY tags.tag_id HAVING cnt > 1 ORDER BY cnt DESC LIMIT 20", new TagStatsMapper()); } @Transactional diff --git a/src/main/java/com/juick/www/api/Tags.java b/src/main/java/com/juick/www/api/Tags.java index c7941925..7d934f38 100644 --- a/src/main/java/com/juick/www/api/Tags.java +++ b/src/main/java/com/juick/www/api/Tags.java @@ -43,9 +43,6 @@ public class Tags { @Visitor User visitor, @RequestParam(required = false, defaultValue = "0") int user_id ) { - if (user_id == 0) { - user_id = visitor.getUid(); - } if (user_id > 0) { return tagService.getUserTagStats(user_id); } -- cgit v1.2.3