This commit is contained in:
Baris Soner Usakli
2013-07-15 14:34:15 -04:00
parent 5819b43595
commit c7a218af9a
3 changed files with 22 additions and 18 deletions

View File

@@ -282,13 +282,17 @@ var RDB = require('./redis.js'),
}
Categories.getRecentReplies = function(cid, count, callback) {
RDB.zrevrange('categories:recent_posts:cid:' + cid, 0, count-1, function(err, pids) {
RDB.zrevrange('categories:recent_posts:cid:' + cid, 0, (count<10)?10:count, function(err, pids) {
if (pids.length == 0) {
callback([]);
return;
}
posts.getPostSummaryByPids(pids, function(posts) {
if(posts.length > count) {
posts = posts.slice(0, count);
}
callback(posts);
});
});