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