mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-10 15:21:56 +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 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();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue