From 68b35770d3f7ec6057c7b16832cbe805008c8ab4 Mon Sep 17 00:00:00 2001 From: milaaraujo Date: Tue, 11 Dec 2018 00:12:52 -0800 Subject: [PATCH 1/3] group by name only --- app/models/tag.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/models/tag.rb b/app/models/tag.rb index f2a3fcf2af..7d687e2a97 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -271,8 +271,7 @@ def self.trending(limit = 5, start_date = DateTime.now - 1.month, end_date = Dat .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 + .group([:name]) # ONLY_FULL_GROUP_BY, issue #3120 (?) .order('count DESC') .limit(limit) end From 38eeb00a6859826be234c97564fb31519175d187 Mon Sep 17 00:00:00 2001 From: milaaraujo Date: Tue, 11 Dec 2018 20:18:42 -0800 Subject: [PATCH 2/3] removing group by --- 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 7d687e2a97..0cfb1cb749 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -266,12 +266,12 @@ def followers_who_dont_follow_tags(tags) end 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) - .group([:name]) # ONLY_FULL_GROUP_BY, issue #3120 (?) + .distinct .order('count DESC') .limit(limit) end From fa3db4c2df5db72788e289ea08329fac615fdcd8 Mon Sep 17 00:00:00 2001 From: milaaraujo Date: Tue, 11 Dec 2018 20:22:16 -0800 Subject: [PATCH 3/3] adding link --- app/models/tag.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/tag.rb b/app/models/tag.rb index 0cfb1cb749..42ac87db31 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -265,6 +265,7 @@ 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.select([:name]) .joins(:node_tag, :node)