From bb48d317502e73f6e236c7870e74da174e021050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camila=20Ara=C3=BAjo?= Date: Tue, 11 Dec 2018 21:05:20 -0800 Subject: [PATCH] Trending tags showing duplicates: group only by name (#4266) * group by name only * removing group by * adding link --- app/models/tag.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/tag.rb b/app/models/tag.rb index f2a3fcf2af..42ac87db31 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -265,14 +265,14 @@ def followers_who_dont_follow_tags(tags) tag_followers.reject { |user| following_given_tags.include? user } end + # https://github.com/publiclab/plots2/pull/4266 def self.trending(limit = 5, start_date = DateTime.now - 1.month, end_date = DateTime.now) - Tag.joins(:node_tag, :node) - .select('node.nid, node.created, node.status, term_data.*, community_tags.*') + Tag.select([:name]) + .joins(:node_tag, :node) .where('node.status = ?', 1) .where('node.created > ?', start_date.to_i) .where('node.created <= ?', end_date.to_i) .distinct - .group([:name, 'node.nid', 'term_data.tid', 'community_tags.nid', 'community_tags.uid', 'community_tags.date']) # ONLY_FULL_GROUP_BY, issue #3120 .order('count DESC') .limit(limit) end