From 81306fff3c59b5d0124f78c66fd879b968d6da64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Mon, 25 Mar 2019 12:06:32 -0400 Subject: [PATCH] feat: allow multiple cids for getActiveUsers --- src/categories/activeusers.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/categories/activeusers.js b/src/categories/activeusers.js index 40ff7bc016..726f612a6a 100644 --- a/src/categories/activeusers.js +++ b/src/categories/activeusers.js @@ -7,10 +7,13 @@ var posts = require('../posts'); var db = require('../database'); module.exports = function (Categories) { - Categories.getActiveUsers = function (cid, callback) { + Categories.getActiveUsers = function (cids, callback) { + if (!Array.isArray(cids)) { + cids = [cids]; + } async.waterfall([ function (next) { - db.getSortedSetRevRange('cid:' + cid + ':pids', 0, 24, next); + db.getSortedSetRevRange(cids.map(cid => 'cid:' + cid + ':pids'), 0, 24, next); }, function (pids, next) { posts.getPostsFields(pids, ['uid'], next);