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.
29 lines
651 B
JavaScript
29 lines
651 B
JavaScript
'use strict';
|
|
|
|
var async = require('async');
|
|
var _ = require('lodash');
|
|
|
|
var posts = require('../posts');
|
|
var db = require('../database');
|
|
|
|
module.exports = function (Categories) {
|
|
Categories.getActiveUsers = function (cids, callback) {
|
|
if (!Array.isArray(cids)) {
|
|
cids = [cids];
|
|
}
|
|
async.waterfall([
|
|
function (next) {
|
|
db.getSortedSetRevRange(cids.map(cid => 'cid:' + cid + ':pids'), 0, 24, next);
|
|
},
|
|
function (pids, next) {
|
|
posts.getPostsFields(pids, ['uid'], next);
|
|
},
|
|
function (posts, next) {
|
|
var uids = _.uniq(posts.map(post => post.uid).filter(uid => uid));
|
|
|
|
next(null, uids);
|
|
},
|
|
], callback);
|
|
};
|
|
};
|