mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 00:15:46 +01:00
active users cleanup
This commit is contained in:
@@ -1,23 +1,23 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async'),
|
||||||
db = require('./../database'),
|
db = require('../database');
|
||||||
posts = require('./../posts'),
|
|
||||||
topics = require('./../topics');
|
|
||||||
|
|
||||||
module.exports = function(Categories) {
|
module.exports = function(Categories) {
|
||||||
|
|
||||||
Categories.getActiveUsers = function(cid, callback) {
|
Categories.getActiveUsers = function(cid, callback) {
|
||||||
db.getSortedSetRevRange('categories:recent_posts:cid:' + cid, 0, 99, function(err, pids) {
|
async.waterfall([
|
||||||
var keys = pids.map(function(pid) {
|
function(next) {
|
||||||
return 'post:' + pid;
|
db.getSortedSetRevRange('categories:recent_posts:cid:' + cid, 0, 99, next);
|
||||||
});
|
},
|
||||||
|
function(pids, next) {
|
||||||
db.getObjectsFields(keys, ['uid'], function(err, users) {
|
var keys = pids.map(function(pid) {
|
||||||
if (err) {
|
return 'post:' + pid;
|
||||||
return callback(err);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
db.getObjectsFields(keys, ['uid'], next);
|
||||||
|
},
|
||||||
|
function(users, next) {
|
||||||
var uids = users.map(function(user) {
|
var uids = users.map(function(user) {
|
||||||
return user.uid;
|
return user.uid;
|
||||||
}).filter(function(value, index, array) {
|
}).filter(function(value, index, array) {
|
||||||
@@ -25,7 +25,7 @@ module.exports = function(Categories) {
|
|||||||
}).slice(0, 24);
|
}).slice(0, 24);
|
||||||
|
|
||||||
callback(null, uids);
|
callback(null, uids);
|
||||||
});
|
}
|
||||||
});
|
], callback);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user