<commit_before>var mongoose = require('mongoose');
var Volunteer = mongoose.model('Volunteer')

var sendJsonResponse = function(res, status, content) {
  res.status(status);
  res.json(content);
}


module.exports.volunteersCreate = function(req, res) {
  console.log('req.body:');
  console.log(req.body);

  var variable_name = "";

  // Create and fill volunteer object
  var volunteer = {};

  volunteer.first_name = req.body.first_name;
  volunteer.last_name = req.body.last_name;
  volunteer.cell_number = req.body.cell_number;
  volunteer.home_number = req.body.home_number;
  volunteer.email = req.body.email;

  // Subscribe
  if (req.body.subscribe == "Yes") {
    volunteer.subscribe = true;
  }
  else {
    volunteer.subscribe = false;
  }

  // Opportunity categories
  volunteer.opportunity_categories = [];
  for (var i = 0; i < global.my_app_config.opportunity_categories.length; i++) {
    variable_name = "req.body.opportunity_category_" + parseInt(i);
    // console.log('variable_name: ', variable_name);
    if ( eval(variable_name) == "on") {
      volunteer.opportunity_categories.push(i);
    }
  }
  // console.log('opportunity_categories: ', volunteer.opportunity_categories);

  // Languages
  volunteer.languages = [];
  for (var i = 0; i < global.my_app_config.languages.length; i++) {
    variable_name = "req.body.languages" + parseInt(i);
    if ( eval(variable_name) == "on") {
      volunteer.languages.push(i);
    }
  }

  console.log('typeof(req.body.how_often): ', typeof(req.body.how_often));
  volunteer.how_often = req.body.how_often;

  // Times of Day
  volunteer.times_of_day = [];
  for (var i = 0; i < global.my_app_config.times_of_day.length; i++) {
    variable_name = "req.body.times_of_day_" + parseInt(i);
    // console.log('variable_name: ', variable_name);
    if ( eval(variable_name) == "on") {
      volunteer.times_of_day.push(i);
    }
  }

  // Reliable Transportation
  console.log('typeof(req.body.reliable_transportation): ', typeof(req.body.reliable_transportation));
  if (req.body.reliable_transportation == "Yes") {
    volunteer.reliable_transportation = true;
  }
  else {
    volunteer.reliable_transportation = false;<commit_msg>fixed storing of languages in DB<commit_after>var mongoose = require('mongoose');
var Volunteer = mongoose.model('Volunteer')

var sendJsonResponse = function(res, status, content) {
  res.status(status);
  res.json(content);
}


module.exports.volunteersCreate = function(req, res) {
  console.log('req.body:');
  console.log(req.body);

  var variable_name = "";

  // Create and fill volunteer object
  var volunteer = {};

  volunteer.first_name = req.body.first_name;
  volunteer.last_name = req.body.last_name;
  volunteer.cell_number = req.body.cell_number;
  volunteer.home_number = req.body.home_number;
  volunteer.email = req.body.email;

  // Subscribe
  if (req.body.subscribe == "Yes") {
    volunteer.subscribe = true;
  }
  else {
    volunteer.subscribe = false;
  }

  // Opportunity categories
  volunteer.opportunity_categories = [];
  for (var i = 0; i < global.my_app_config.opportunity_categories.length; i++) {
    variable_name = "req.body.opportunity_category_" + parseInt(i);
    // console.log('variable_name: ', variable_name);
    if ( eval(variable_name) == "on") {
      volunteer.opportunity_categories.push(i);
    }
  }
  // console.log('opportunity_categories: ', volunteer.opportunity_categories);

  // Languages
  volunteer.languages = [];
  for (var i = 0; i < global.my_app_config.languages.length; i++) {
    variable_name = "req.body.language_" + parseInt(i);
    if ( eval(variable_name) == "on") {
      volunteer.languages.push(i);
    }
  }

  console.log('typeof(req.body.how_often): ', typeof(req.body.how_often));
  volunteer.how_often = req.body.how_often;

  // Times of Day
  volunteer.times_of_day = [];
  for (var i = 0; i < global.my_app_config.times_of_day.length; i++) {
    variable_name = "req.body.times_of_day_" + parseInt(i);
    // console.log('variable_name: ', variable_name);
    if ( eval(variable_name) == "on") {
      volunteer.times_of_day.push(i);
    }
  }

  // Reliable Transportation
  console.log('typeof(req.body.reliable_transportation): ', typeof(req.body.reliable_transportation));
  if (req.body.reliable_transportation == "Yes") {
    volunteer.reliable_transportation = true;
  }
  else {
    volunteer.reliable_transportation = false;
{'fraction_non_alphanumeric': 0.1465731734901606, 'fraction_numerical': 0.0013571590137977834, 'mean_word_length': 3.848684210526316, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1987141', 'n_tokens_mistral': 1519, 'n_tokens_neox': 1513, 'n_words': 242}