From e8b767d0dd378b22048803d3375263c90613407c Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 29 Jul 2014 01:36:33 -0400 Subject: [PATCH] get recent poster uids --- src/posts.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/posts.js b/src/posts.js index c6869b180b..9e06528f2b 100644 --- a/src/posts.js +++ b/src/posts.js @@ -188,6 +188,36 @@ var async = require('async'), }); }; + Posts.getRecentPosterUids = function(start, end, callback) { + db.getSortedSetRevRange('posts:pid', start, end, function(err, pids) { + if (err) { + return callback(err); + } + + if (!Array.isArray(pids) || !pids.length) { + return callback(null, []); + } + + pids = pids.map(function(pid) { + return 'post:' + pid; + }); + + db.getObjectsFields(pids, ['uid'], function(err, postData) { + if (err) { + return callback(err); + } + + postData = postData.map(function(post) { + return post && post.uid; + }).filter(function(value, index, array) { + return value && array.indexOf(value) === index; + }); + + callback(null, postData); + }); + }); + }; + Posts.getUserInfoForPosts = function(uids, callback) { user.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) { if (err) {