mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-26 06:10:58 +00:00
Fix user population method
This commit is contained in:
parent
a4e858b2a7
commit
eadb8f3b12
1 changed files with 3 additions and 12 deletions
|
@ -3,27 +3,18 @@
|
|||
var User = require("../user/user");
|
||||
var client = require("../ensl/client")();
|
||||
var async = require("async");
|
||||
var getRandomUser = require("../user/helper").getRandomUser;
|
||||
|
||||
var createTestUsers = (options, callback) => {
|
||||
var gather = options.gather;
|
||||
|
||||
var getRandomUser = callback => {
|
||||
var id = Math.floor(Math.random() * 5000) + 1;
|
||||
client.getUserById({
|
||||
id: id
|
||||
}, (error, response, body) => {
|
||||
if (response.statusCode !== 200) return getRandomUser(callback);
|
||||
return callback(error, response, body);
|
||||
});
|
||||
};
|
||||
|
||||
var instructions = [];
|
||||
for (var i = 0; i < 11; i++) {
|
||||
instructions.push(callback => {
|
||||
getRandomUser((error, response, body) => {
|
||||
getRandomUser((error, user) => {
|
||||
if (error) return callback(error);
|
||||
if (gather.can("addGatherer")) {
|
||||
gather.addGatherer(new User(body));
|
||||
gather.addGatherer(user);
|
||||
}
|
||||
callback();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue