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

18 lines
488 B
JavaScript

'use strict';
const _ = require('lodash');
const posts = require('../posts');
const db = require('../database');
module.exports = function (Categories) {
Categories.getActiveUsers = async function (cids) {
if (!Array.isArray(cids)) {
cids = [cids];
}
const pids = await db.getSortedSetRevRange(cids.map(cid => `cid:${cid}:pids`), 0, 24);
const postData = await posts.getPostsFields(pids, ['uid']);
return _.uniq(postData.map(post => post.uid).filter(uid => uid));
};
};