diff --git a/app/models/node_tag.rb b/app/models/node_tag.rb index fc0229c983..4944d54eb5 100644 --- a/app/models/node_tag.rb +++ b/app/models/node_tag.rb @@ -8,13 +8,11 @@ class NodeTag < ApplicationRecord has_many :tag_selections, foreign_key: 'tid' accepts_nested_attributes_for :tag - after_create :increment_count + after_create :update_count + after_destroy :update_count - def increment_count - tag = self.tag - tag.count = 0 if tag.count.nil? - tag.count += 1 - tag.save + def update_count + tag.run_count # update count of tag usage end def user diff --git a/app/models/tag.rb b/app/models/tag.rb index 313634709a..c570f3565f 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -115,14 +115,6 @@ def self.find_nodes_by_type(tagnames, type = 'note', limit = 10) .order(order) end - def self.counter(tagname) - Node.where(type: %w(note page)) - .where('term_data.name = ?', tagname) - .includes(:node_tag, :tag) - .references(:term_data) - .count - end - # just like find_nodes_by_type, but searches wiki pages, places, and tools def self.find_pages(tagnames, limit = 10) find_nodes_by_type(tagnames, %w(page place tool), limit) diff --git a/app/views/tag/_topicCard.html.erb b/app/views/tag/_topicCard.html.erb index 5d8826e30e..819775dd88 100644 --- a/app/views/tag/_topicCard.html.erb +++ b/app/views/tag/_topicCard.html.erb @@ -32,7 +32,7 @@