You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nodebb/src/categories/activeusers.js

29 lines
656 B
JavaScript

'use strict';
var async = require('async'),
posts = require('../posts'),
db = require('../database');
module.exports = function(Categories) {
Categories.getActiveUsers = function(cid, callback) {
async.waterfall([
function(next) {
db.getSortedSetRevRange('cid:' + cid + ':pids', 0, 24, next);
},
function(pids, next) {
posts.getPostsFields(pids, ['uid'], next);
},
function(posts, next) {
var uids = posts.map(function(post) {
return post.uid;
}).filter(function(uid, index, array) {
return parseInt(uid, 10) !== 0 && array.indexOf(uid) === index;
});
next(null, uids);
}
], callback);
};
};