<commit_before>var data = require('../data.json');
var util = require('util');

exports.view = function(req, res){
    var firstname = req.session.firstname;
    var lastname = req.session.lastname;
    var code = req.session.code;
    console.log(req.session);

    console.log(util.inspect(data, {showHidden: false, depth: null}));
    console.log(util.inspect(data, {showHidden: false, depth: null}));
    var passIn = data['meeting'][code];
    passIn['thisSession'] = {
            'code': code,
            'firstname': firstname,
            'lastname': lastname
        };
  	res.render('polling', passIn );
};

exports.pollingSubmit = function(req, res){
    var firstname = req.session.firstname;
    var lastname = req.session.lastname;
    var code = req.session.code;
    var pollingVote = req.body.options;
	var pollingId = req.params.id;
	console.log(data['meeting'][code]['polling'][req.params.id]);
	data['meeting'][code]['polling'][req.params.id]['result'][pollingVote]++;
    var thisUser = {'firstname':firstname, 'lastname':lastname};
    data['meeting'][code]['polling'][req.params.id]['participant'].push(thisUser);
    var thisPolling;
	for (var i = 0; i < data['meeting'][code]['polling'].length; i++) {
		console.log(data['meeting'][code]['polling'][i]);
		if (data['meeting'][code]['polling'][i]['id'] == pollingId) {
			thisPolling = data['meeting'][code]['polling'][i];
			break;
		}
	}
	var passIn = data['meeting'][code];
    passIn['thisSession'] = {
            'code': code,
            'lastname': lastname,
            'firstname': firstname
        };
    passIn['thisPolling'] = thisPolling;
	console.log(util.inspect(data, {
        showHidden: false,
        depth: null
    }));
    console.log('polling.js thisPolling:' + thisPolling);
  	res.render('polling', passIn );
};

exports.create = function(req, res){
    var firstname = req.session.firstname;
    var lastname = req.session.lastname;
    var code = req.session.code;
	var pollingTitle = req.body.pollingTitle;
    var pollingDescription = req.body.pollingDescription;
    var pollingOptions = [];
    var count;
    for (var i=0; i<5; i++) {
      pollingOptions[i] = req.body['pollingOption'+i];
      if (pollingOptions[i] == undefined) {
        count = i+1;
        break;
      }
    }
	var pollingId = data['meeting'][code]['polling'].length;
	var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth()+1; //January is 0!

    var yyyy = today.getFullYear();
    if(dd<10){
        dd='0'+dd
    } 
    if(mm<10){
        mm='0'+mm
    } 
    var today = mm+'/'+dd+'/'+yyyy;
	var pollingData = {
        'id': pollingId,
		'title': pollingTitle,
		'date': today,
		'choice': [
		],
		'result':[]
    };
	for (i=0; i<count; i++)
		if (pollingOptions[i] != undefined){
			pollingData['result'][i] = 0;
			pollingData['choice'].push(pollingOptions[i]);
		}
	console.log(pollingData);
	if (pollingTitle != undefined) {
    	data['meeting'][code]['polling'].push(pollingData);
	}
    console.log(util.inspect(data, {showHidden: false, depth: null}));
    var passIn = data['meeting'][code];
    passIn['thisSession'] = {
            'code': code,
            'lastname': lastname,
            'firstname': firstname
        };
	passIn['thisPolling'] = pollingData;
	res.render('polling', passIn );
}<commit_msg>polling graph fix<commit_after>var data = require('../data.json');
var util = require('util');

exports.view = function(req, res){
    var firstname = req.session.firstname;
    var lastname = req.session.lastname;
    var code = req.session.code;
    var pollingId = req.params.id;
    console.log(req.session);

    console.log(util.inspect(data, {showHidden: false, depth: null}));
    console.log(util.inspect(data, {showHidden: false, depth: null}));
    var passIn = data['meeting'][code];
    passIn['thisSession'] = {
            'code': code,
            'firstname': firstname,
            'lastname': lastname
        };
    var thisPolling = data['meeting'][code]['polling'][pollingId];
    passIn['thisPolling'] = thisPolling;
  	res.render('polling', passIn );
};

exports.pollingSubmit = function(req, res){
    var firstname = req.session.firstname;
    var lastname = req.session.lastname;
    var code = req.session.code;
    var pollingVote = req.body.options;
	var pollingId = req.params.id;
	console.log(data['meeting'][code]['polling'][req.params.id]);
	data['meeting'][code]['polling'][req.params.id]['result'][pollingVote]++;
    var thisUser = {'firstname':firstname, 'lastname':lastname};
    data['meeting'][code]['polling'][req.params.id]['participant'].push(thisUser);
    var thisPolling;
	for (var i = 0; i < data['meeting'][code]['polling'].length; i++) {
		console.log(data['meeting'][code]['polling'][i]);
		if (data['meeting'][code]['polling'][i]['id'] == pollingId) {
			thisPolling = data['meeting'][code]['polling'][i];
			break;
		}
	}
	var passIn = data['meeting'][code];
    passIn['thisSession'] = {
            'code': code,
            'lastname': lastname,
            'firstname': firstname
        };
    passIn['thisPolling'] = thisPolling;
	console.log(util.inspect(data, {
        showHidden: false,
        depth: null
    }));
    console.log('polling.js thisPolling:' + thisPolling);
  	res.render('polling', passIn );
};

exports.create = function(req, res){
    var firstname = req.session.firstname;
    var lastname = req.session.lastname;
    var code = req.session.code;
	var pollingTitle = req.body.pollingTitle;
    var pollingDescription = req.body.pollingDescription;
    var pollingOptions = [];
    var count;
    for (var i=0; i<5; i++) {
      pollingOptions[i] = req.body['pollingOption'+i];
      if (pollingOptions[i] == undefined) {
        count = i+1;
        break;
      }
    }
	var pollingId = data['meeting'][code]['polling'].length;
	var today = new Date();
    var dd = today.getDate();
    var mm = today.getMonth()+1; //January is 0!

    var yyyy = today.getFullYear();
    if(dd<10){
        dd='0'+dd
    } 
    if(mm<10){
        mm='0'+mm
    } 
    var today = mm+'/'+dd+'/'+yyyy;
	var pollingData = {
        'id': pollingId,
		'title': pollingTitle,
		'date': today,
		'choice': [
		],
		'result':[]
    };
	for (i=0; i<count; i++)
		if (pollingOptions[i] != undefined){
			pollingData['result'][i] = 0;
			pollingData['choice'].push(pollingOptions[i]);
		}
	console.log(pollingData);
	if (pollingTitle != undefined) {
    	data['meeting'][code]['polling'].push(pollingData);
	}
    console.log(util.inspect(data, {showHidden: false, depth: null}));
    var passIn = data['meeting'][code];
    passIn['thisSession'] = {
            'code': code,
            'lastname': lastname,
            'firstname': firstname
        };
	passIn['thisPolling'] = pollingData;
	res.render('polling', passIn );
}
{'fraction_non_alphanumeric': 0.18245716796016986, 'fraction_numerical': 0.004100161077756626, 'mean_word_length': 3.274092615769712, 'pattern_counts': {'":': 0, '<': 13, '<?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': '1154669', 'n_tokens_mistral': 2399, 'n_tokens_neox': 2339, 'n_words': 428}