FIX: tags index should show all tags belonging to a category even if they have never been used
This commit is contained in:
parent
5ba8612fa8
commit
3c0df3510a
|
@ -6,7 +6,11 @@
|
|||
{{/if}}
|
||||
{{#each sortedTags as |tag|}}
|
||||
<div class='tag-box'>
|
||||
{{discourse-tag tag.id}} <span class='tag-count'>x {{tag.count}}</span>
|
||||
{{#if tag.count}}
|
||||
{{discourse-tag tag.id}} <span class='tag-count'>x {{tag.count}}</span>
|
||||
{{else}}
|
||||
{{discourse-tag tag.id}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/each}}
|
||||
<div class="clearfix" />
|
||||
|
|
|
@ -15,7 +15,11 @@ class TagsController < ::ApplicationController
|
|||
categories = Category.where("id in (select category_id from category_tags)")
|
||||
.where("id in (?)", guardian.allowed_category_ids)
|
||||
.preload(:tags)
|
||||
category_tag_counts = categories.map { |c| {id: c.id, tags: self.class.tag_counts_json(Tag.category_tags_by_count_query(c, limit: 300).count)} }
|
||||
category_tag_counts = categories.map do |c|
|
||||
h = Tag.category_tags_by_count_query(c, limit: 300).count
|
||||
h.merge!(c.tags.where.not(name: h.keys).inject({}) { |sum,t| sum[t.name] = 0; sum }) # unused tags
|
||||
{id: c.id, tags: self.class.tag_counts_json(h)}
|
||||
end
|
||||
|
||||
tag_counts = self.class.tags_by_count(guardian, limit: 300).count
|
||||
@tags = self.class.tag_counts_json(tag_counts)
|
||||
|
|
Loading…
Reference in New Issue