<commit_before>var Game = require('./gameModel');

var makeGame = function(req, res, next){

  var game = {
    _id: req.body.id,
    players: [],
    questions: [1,2,3,4,5,6,7] // hard coded question numbers and round numbers
  };

  var newGame = new Game(game);
  newGame.save(function(err, newEntry){
    if (err){
      console.log("ERROR", err);
      res.send(500, {err: err});
    }else{
      console.log("SUCCESS", newEntry);
      res.send(200, {entry: newEntry});
    }
  });
};

var getGame = function(req, res, next){

  console.log("req.body", req.body);
  console.log("req.body.code", req.body.code);

  Game.findById(req.body.code).exec(function(err, data){
    if (err){
      console.log("ERROR: ", err);
      res.send(500,err);
    }else{
      res.status(200).send(data);
    }
  });

};

var updateGame = function(req,res,next){
  Game.findByIdAndUpdate(
      req.body.code,
      {$push: {"players": {name: "hardcode"}}},
      {safe: true, upsert: true, new: true},
      function(err, model){
        if (err){
          console.log("ERROR: ", err);
          res.send(500, err);
        }else{
          res.status(200).send(model);
        }
      }
    );
};

module.exports = {
  makeGame: makeGame,
  getGame: getGame,
  updateGame: updateGame
};<commit_msg>Properly pushing players into the game.players array<commit_after>var Game = require('./gameModel');

var makeGame = function(req, res, next){

  var game = {
    _id: req.body.id,
    players: [],
    questions: [1,2,3,4,5,6,7] // hard coded question numbers and round numbers
  };

  var newGame = new Game(game);
  newGame.save(function(err, newEntry){
    if (err){
      console.log("ERROR", err);
      res.send(500, {err: err});
    }else{
      console.log("SUCCESS", newEntry);
      res.send(200, {entry: newEntry});
    }
  });
};

var getGame = function(req, res, next){

  console.log("req.body", req.body);
  console.log("req.body.code", req.body.code);

  Game.findById(req.body.code).exec(function(err, data){
    if (err){
      console.log("ERROR: ", err);
      res.send(500,err);
    }else{
      res.status(200).send(data);
    }
  });

};

var updateGame = function(req,res,next){
  Game.findOneAndUpdate(
      {"_id":req.body.code},
      {$push: {"players": {username: "hardcode", currentRound: 1}}},
      {safe: true, upsert: true, new: true},
      function(err, model){
        if (err){
          console.log("ERROR: ", err);
          res.send(500, err);
        }else{
          res.status(200).send(model);
        }
      }
    );
};

module.exports = {
  makeGame: makeGame,
  getGame: getGame,
  updateGame: updateGame
};
{'fraction_non_alphanumeric': 0.18284850774461656, 'fraction_numerical': 0.01926709482432943, 'mean_word_length': 2.7191011235955056, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, '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': '2109160', 'n_tokens_mistral': 963, 'n_tokens_neox': 927, 'n_words': 190}