From 50feb7a7663636407ea52da5ff28a9102919a214 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sun, 19 Apr 2015 15:24:11 -0400 Subject: [PATCH] default to zero if post_count topic_count is falsy --- src/categories.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/categories.js b/src/categories.js index d1621921f0..6112c5dc58 100644 --- a/src/categories.js +++ b/src/categories.js @@ -253,8 +253,12 @@ var async = require('async'), if (!Array.isArray(category.children) || !category.children.length) { return; } + var postCount = parseInt(category.post_count, 10) || 0; + var topicCount = parseInt(category.topic_count, 10) || 0; category.children.forEach(function(child) { + postCount += parseInt(child.post_count, 10) || 0; + topicCount += parseInt(child.topic_count, 10) || 0; }); category.post_count = postCount; category.topic_count = topicCount;