<commit_before>'use strict'

/**
 * Dependencies
 * @ignore
 */
const moment = require('moment')

/**
 * Module Dependencies
 * @ignore
 */
const BaseRequest = require('../BaseRequest')

/**
 * NewGameRequest
 * @class
 */
class NewGameRequest extends BaseRequest {

  static handle (request, socket, system) {
    let instance = new NewGameRequest(request, socket, system)

    return Promise.resolve(instance)
      .then(instance.authenticated)
      .then(instance.create)
      .then(instance.success)
      .catch(error => instance.internalServerError(error))
  }

  create (instance) {
    let { log } = NewGameRequest
    let { request, socket, system } = instance
    let { gameManager } = system
    let { data: { name, description, background_image, registration_date, start_date, end_date, rules } } = request
    let { handshake: { session: { sub: id } } } = socket

    if (!name) {
      return Promise.reject('name is required to create a new game')
    }

    if (!registration_date) {
      return Promise.reject('registration_date is required to create a new game')
    }

    if (!start_date) {
      return Promise.reject('registration_date is required to create a new game')
    }

    if (!end_date) {
      return Promise.reject('registration_date is required to create a new game')
    }

    let game = {
      name,<commit_msg>fix(NewGameRequest): check correct date variables<commit_after>'use strict'

/**
 * Dependencies
 * @ignore
 */
const moment = require('moment')

/**
 * Module Dependencies
 * @ignore
 */
const BaseRequest = require('../BaseRequest')

/**
 * NewGameRequest
 * @class
 */
class NewGameRequest extends BaseRequest {

  static handle (request, socket, system) {
    let instance = new NewGameRequest(request, socket, system)

    return Promise.resolve(instance)
      .then(instance.authenticated)
      .then(instance.create)
      .then(instance.success)
      .catch(error => instance.internalServerError(error))
  }

  create (instance) {
    let { log } = NewGameRequest
    let { request, socket, system } = instance
    let { gameManager } = system
    let { data: { name, description, background_image, registration_date, start_date, end_date, rules } } = request
    let { handshake: { session: { sub: id } } } = socket

    if (!name) {
      return Promise.reject('name is required to create a new game')
    }

    if (!registration_date) {
      return Promise.reject('registration_date is required to create a new game')
    }

    if (!start_date) {
      return Promise.reject('start_date is required to create a new game')
    }

    if (!end_date) {
      return Promise.reject('end_date is required to create a new game')
    }

    let game = {
      name,
{'fraction_non_alphanumeric': 0.11546920821114369, 'fraction_numerical': 0.0, 'mean_word_length': 3.1161387631975868, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5990014', 'n_tokens_mistral': 794, 'n_tokens_neox': 765, 'n_words': 229}