FIX: use 'topic_all_time' as topic count failover in /categories page

This commit is contained in:
Régis Hanol 2016-08-29 10:25:46 +02:00
parent 70a1d8bce8
commit 5833e96017
2 changed files with 7 additions and 2 deletions

View File

@ -48,8 +48,8 @@ CategoryList.reopenClass({
break;
}
default:
c.stat = `<span class="value">${c.topic_count}</span>`;
c.statTitle = I18n.t("categories.topic_sentence", { count: c.topic_count });
c.stat = `<span class="value">${c.topics_all_time}</span>`;
c.statTitle = I18n.t("categories.topic_sentence", { count: c.topics_all_time });
break;
}

View File

@ -6,6 +6,7 @@ class CategoryDetailedSerializer < BasicCategorySerializer
:topics_week,
:topics_month,
:topics_year,
:topics_all_time,
:description_excerpt,
:is_uncategorized,
:subcategory_ids
@ -48,6 +49,10 @@ class CategoryDetailedSerializer < BasicCategorySerializer
count_with_subcategories(:topics_year)
end
def topics_all_time
count_with_subcategories(:topic_count)
end
def count_with_subcategories(method)
count = object.send(method) || 0
object.subcategories.each do |category|