async.each for get_userslugs_by_uids

This commit is contained in:
Baris Soner Usakli
2013-07-05 18:19:55 -04:00
parent 884a259909
commit 1c855ce502
2 changed files with 24 additions and 5 deletions

View File

@@ -531,10 +531,23 @@ var utils = require('./../public/src/utils.js'),
return callback([]);
}
function iterator(uid, callback) {
User.getUserField(uid, 'userslug', function(userslug) {
userslugs.push(userslug);
callback(null);
});
}
async.each(uids, iterator, function(err) {
callback(userslugs);
});
// @todo - rework this logic. it doesn't make much sense when you're going through
// each and then placing the check logic into the innermost callback.
// this is probably a situation where an async.method is ideal
for(var i=0, ii=uids.length; i<ii; ++i) {
/*for(var i=0, ii=uids.length; i<ii; ++i) {
User.getUserField(uids[i],'userslug', function(userslug) {
userslugs.push(userslug);
@@ -542,7 +555,7 @@ var utils = require('./../public/src/utils.js'),
callback(userslugs);
}
});
}
}*/
}
User.get_uid_by_email = function(email, callback) {