mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 18:56:15 +01:00
closes #2264
This commit is contained in:
@@ -113,31 +113,50 @@ module.exports = function(Categories) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var keys = pids.map(function(pid) {
|
var start = 0,
|
||||||
return 'post:' + pid;
|
done = false,
|
||||||
});
|
batch = 50;
|
||||||
|
|
||||||
db.getObjectsFields(keys, ['timestamp'], function(err, postData) {
|
async.whilst(function() {
|
||||||
if (err) {
|
return !done;
|
||||||
return winston.error(err.message);
|
}, function(next) {
|
||||||
|
var movePids = pids.slice(start, start + batch);
|
||||||
|
if (!movePids.length) {
|
||||||
|
done = true;
|
||||||
|
return next();
|
||||||
}
|
}
|
||||||
|
var keys = movePids.map(function(pid) {
|
||||||
var timestamps = postData.map(function(post) {
|
return 'post:' + pid;
|
||||||
return post && post.timestamp;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async.parallel([
|
db.getObjectsFields(keys, ['timestamp'], function(err, postData) {
|
||||||
function(next) {
|
|
||||||
db.sortedSetRemove('categories:recent_posts:cid:' + oldCid, pids, next);
|
|
||||||
},
|
|
||||||
function(next) {
|
|
||||||
db.sortedSetAdd('categories:recent_posts:cid:' + cid, timestamps, pids, next);
|
|
||||||
}
|
|
||||||
], function(err) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
winston.error(err.message);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var timestamps = postData.map(function(post) {
|
||||||
|
return post && post.timestamp;
|
||||||
|
});
|
||||||
|
|
||||||
|
async.parallel([
|
||||||
|
function(next) {
|
||||||
|
db.sortedSetRemove('categories:recent_posts:cid:' + oldCid, movePids, next);
|
||||||
|
},
|
||||||
|
function(next) {
|
||||||
|
db.sortedSetAdd('categories:recent_posts:cid:' + cid, timestamps, movePids, next);
|
||||||
|
}
|
||||||
|
], function(err) {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
start += batch;
|
||||||
|
next();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
}, function(err) {
|
||||||
|
if (err) {
|
||||||
|
winston.error(err.stack);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user