Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect tag count in /tags route #7609

Merged
merged 2 commits into from Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
Uzay-G marked this conversation as resolved.
Show resolved Hide resolved
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