mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
closes #80
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
28
src/posts.js
28
src/posts.js
@@ -57,24 +57,24 @@ marked.setOptions({
|
||||
|
||||
var returnData = [];
|
||||
|
||||
var loaded = 0;
|
||||
function getPostSummary(pid, callback) {
|
||||
Posts.getPostFields(pid, ['pid', 'content', 'uid', 'timestamp', 'deleted'], function(postData) {
|
||||
Posts.addUserInfoToPost(postData, function() {
|
||||
|
||||
for(var i=0, ii=pids.length; i<ii; ++i) {
|
||||
if(postData.deleted !== '1') {
|
||||
returnData.push(postData);
|
||||
}
|
||||
|
||||
(function(index, pid) {
|
||||
Posts.getPostFields(pids[i], ['pid', 'content', 'uid', 'timestamp'], function(postData) {
|
||||
Posts.addUserInfoToPost(postData, function() {
|
||||
|
||||
returnData[index] = postData;
|
||||
++loaded;
|
||||
|
||||
if(loaded === pids.length) {
|
||||
callback(returnData);
|
||||
}
|
||||
});
|
||||
callback(null);
|
||||
});
|
||||
}(i, pids[i]));
|
||||
});
|
||||
}
|
||||
|
||||
async.eachSeries(pids, getPostSummary, function(err) {
|
||||
if(!err) {
|
||||
callback(returnData);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Posts.getPostData = function(pid, callback) {
|
||||
|
||||
@@ -305,7 +305,7 @@ marked.setOptions({
|
||||
|
||||
Topics.getTeaser = function(tid, callback) {
|
||||
Topics.get_latest_undeleted_pid(tid, function(pid) {
|
||||
console.log(pid);
|
||||
|
||||
if (pid !== null) {
|
||||
|
||||
posts.getPostFields(pid, ['content', 'uid', 'timestamp'], function(postData) {
|
||||
|
||||
Reference in New Issue
Block a user