'use strict';

const rethinkDB = require('rethinkdb');
const program = require('commander');

const log = require('./../server/log');

export class CoralUserGenerator {
  constructor (conn, number, startLocationId) {
    this.conn = conn;
    this.name = 'coral';
    this.number = number;

    this.user = {x: 0, y: 0, direction: 'up', login: undefined, location: startLocationId};
  }

  generate () {
    rethinkDB
      .tableCreate('userPosition')
      .run(this.conn, (err) => {
        if (err) throw err;

        let login;

        for (let i = 0; i < this.number; i++) {
          this.user.login = `${this.name}${i}`;

          log.info(`Create test user ${this.user.login}`);

          rethinkDB
            .table('userPosition')
            .insert(this.user)
            .run(this.conn, (err) => {
              if (err) throw err;
            });
        }
      });
  }
}


@@ -305,19 +305,38 @@
  = %7B
-x: 0, y: 0,
+%0A      x: 0,%0A      y: 0,%0A     
  dir
@@ -348,16 +348,22 @@
 n: 'up',
+%0A     
  login: 
@@ -372,16 +372,22 @@
 defined,
+%0A     
  locatio
@@ -404,16 +404,37 @@
 cationId
+,%0A      online: false
 %7D;%0A  %7D%0A%0A

add online field