Skip to content

Commit

Permalink
tag graph trimming (#4727)
Browse files Browse the repository at this point in the history
  • Loading branch information
jywarren committed Jan 29, 2019
1 parent 9a25968 commit eb405fd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def self.related(tag_name, count = 5)
.where(NodeTag.table_name => { nid: nids })
.where.not(name: tag_name)
.group(:tid)
.order('COUNT(term_data.tid) DESC')
.order(count: :desc)
.limit(count)
end
end
Expand All @@ -335,7 +335,10 @@ def self.graph_data(limit = 250)
Rails.cache.fetch("graph-data/#{limit}", expires_in: 1.weeks) do
data = {}
data["tags"] = []
Tag.order(count: :desc).limit(limit).each do |tag|
Tag.joins(:node_tag)
.group(:tid)
.order(count: :desc)
.limit(limit).each do |tag|
data["tags"] << {
"name" => tag.name,
"count" => tag.count
Expand Down

0 comments on commit eb405fd

Please sign in to comment.