Files
NodeBB/src/categories/activeusers.js

29 lines
659 B
JavaScript
Raw Normal View History

2014-03-12 21:41:53 -04:00
'use strict';
2016-02-10 13:05:02 +02:00
var async = require('async');
var posts = require('../posts');
var db = require('../database');
2014-03-12 21:41:53 -04:00
module.exports = function(Categories) {
2014-04-24 18:59:19 -04:00
Categories.getActiveUsers = function(cid, callback) {
2014-07-13 14:57:55 -04:00
async.waterfall([
2016-02-10 13:05:02 +02:00
function (next) {
2014-11-07 17:15:01 -05:00
db.getSortedSetRevRange('cid:' + cid + ':pids', 0, 24, next);
2014-07-13 14:57:55 -04:00
},
2016-02-10 13:05:02 +02:00
function (pids, next) {
posts.getPostsFields(pids, ['uid'], next);
2014-07-13 14:57:55 -04:00
},
2016-02-10 13:05:02 +02:00
function (posts, next) {
var uids = posts.map(function(post) {
return post.uid;
}).filter(function(uid, index, array) {
2016-02-10 13:05:02 +02:00
return parseInt(uid, 10) && array.indexOf(uid) === index;
2014-11-23 00:32:31 -05:00
});
2014-03-12 21:41:53 -04:00
2014-11-15 21:52:05 -05:00
next(null, uids);
2014-07-13 14:57:55 -04:00
}
], callback);
2014-03-12 21:41:53 -04:00
};
2014-04-10 20:31:57 +01:00
};