Skip to content

Commit

Permalink
Fix incorrect tag count in /tags route (#7609)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlazypanda committed Apr 14, 2020
1 parent dc6a61f commit 81df65f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/models/tag.rb
Expand Up @@ -115,6 +115,14 @@ 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)
Expand Down
2 changes: 1 addition & 1 deletion app/views/tag/_topicCard.html.erb
Expand Up @@ -32,7 +32,7 @@
</div>
<div class="card-footer" style="background-color: inherit; border:none;">
<a style="padding-top:15px;text-decoration:underline;color:#808080;display:inline-block;" href="/tag/<%= tag.name %>"><%= tag.count %> <%= translation('tag.index.more_posts') %> &raquo;</a>
<a style="padding-top:15px;text-decoration:underline;color:#808080;display:inline-block;" href="/tag/<%= tag.name %>"><%= Tag.counter(tag.name)-shown_nids.count - Tag.find_nodes_by_type(tag.name, type = 'note', limit = 3).where.not(nid: shown_nids).count %> <%= translation('tag.index.more_posts') %> &raquo;</a>
<div id="follow-unfollow-column-<%=tag.tid%>" style="float:right;margin:10px 0 10px 10px;">
<% if current_user %>
<% if !current_user.following(tag.name) %>
Expand Down

0 comments on commit 81df65f

Please sign in to comment.