From cd08a16f7765f4e17917ad0339c37a353b853b70 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 19 May 2014 19:24:06 -0400 Subject: [PATCH] return post count to with categories --- src/categories.js | 29 ++++++++++++++++++----------- src/controllers/index.js | 6 ++++-- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/categories.js b/src/categories.js index 06b96c5c84..0203afa6ba 100644 --- a/src/categories.js +++ b/src/categories.js @@ -171,6 +171,10 @@ var db = require('./database'), }); }; + Categories.getPostCount = function(cid, callback) { + db.sortedSetCard('categories:recent_posts:cid:' + cid, callback); + }; + Categories.getAllCategories = function(uid, callback) { db.getSortedSetRange('categories:cid', 0, -1, function(err, cids) { if (err) { @@ -215,7 +219,6 @@ var db = require('./database'), }; Categories.hasReadCategories = function(cids, uid, callback) { - var sets = []; for (var i = 0, ii = cids.length; i < ii; i++) { @@ -237,7 +240,7 @@ var db = require('./database'), Categories.getCategoriesData = function(cids, callback) { var keys = cids.map(function(cid) { - return 'category:'+cid; + return 'category:' + cid; }); db.getObjects(keys, function(err, categories) { @@ -249,15 +252,19 @@ var db = require('./database'), return callback(null, []); } - for (var i=0; i 2 ? 2 : posts.length; // this was a hack to make metro work back in the day, post_count should just = length - callback(null); + callback(); }); }