Fix user population method

This commit is contained in:
Chris Blanchard 2015-08-28 15:17:02 +01:00
parent a4e858b2a7
commit eadb8f3b12

View file

@ -3,27 +3,18 @@
var User = require("../user/user"); var User = require("../user/user");
var client = require("../ensl/client")(); var client = require("../ensl/client")();
var async = require("async"); var async = require("async");
var getRandomUser = require("../user/helper").getRandomUser;
var createTestUsers = (options, callback) => { var createTestUsers = (options, callback) => {
var gather = options.gather; 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 = []; var instructions = [];
for (var i = 0; i < 11; i++) { for (var i = 0; i < 11; i++) {
instructions.push(callback => { instructions.push(callback => {
getRandomUser((error, response, body) => { getRandomUser((error, user) => {
if (error) return callback(error); if (error) return callback(error);
if (gather.can("addGatherer")) { if (gather.can("addGatherer")) {
gather.addGatherer(new User(body)); gather.addGatherer(user);
} }
callback(); callback();
}); });