Skip to content

Commit

Permalink
Trending tags showing duplicates: group only by name (#4266)
Browse files Browse the repository at this point in the history
* group by name only

* removing group by

* adding link
  • Loading branch information
milaaraujo authored and jywarren committed Dec 12, 2018
1 parent 90e7acf commit bb48d31
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bb48d31

Please sign in to comment.