<commit_before>var Query = require('../../classes/query');
var converter = require('../../classes/converter');

/**
 * get list of sesssions for user which are not finished.
 * @param {object} req - request object.
 * @param {object} res - response object.
 * @returns {array} - array with objects containing id and name of session
 */
exports.all = function(req, res) {
	var qstr = 'SELECT idsessions, name FROM sessions WHERE users_idusers = ' + req.params.user_id ' AND finished = 0';

	var query = new Query;
	
	// TODO: session filter devices, apps 

	query.execute(qstr, '', function(rows) {
		res.send(rows);
	});
};

/**
 * get one session for user.
 * @param {object} req - request object.
 * @param {object} res - response object.
 *
 * @returns {object} - JSON object containing the session information
 */
exports.get = function(req, res) {
	
	console.log(req.params.session_id);
	
	var qstr = 'SELECT * FROM sessions WHERE users_idusers = ' + req.params.user_id + ' AND idsessions = ' + req.params.session_id;
	var query = new Query;
	
	query.execute(qstr, '', function(rows){
		res.send(rows);
	});
	
}

/**
 * updates a session.
 * @param {object} req - Request object
 * @param {object} res - Response object
 *
 */
exports.put = function(req, res) {
	
	// TODO check params 

	qstr = 'UPDATE sessions SET ';

	if( req.params.active != undefinded && req.params.active != '') { 
		// set active
		qstr += ' active = ' + req.params.active;
	} else if (req.params.name != undefined && req.params.name != '') { 
		// change name
		qstr += ' name = ' + req.params.name;
	} else if (req.params.finished != undefined) {
		// set finished
		
		// TODO  send 409 on finish not successfully
		// successfully is when logs and captures are already uploaded/added to the session. 
		qstr += ' name = ' + req.params.finished;
	}

	qstr += 'WHERE idsessions = ' req.params.session_id; 

	// TODO error check
	query.execute(qstr, '', function(rows){
		// send to user
		res.send(rows);
	});
<commit_msg>forgot some concatinators :)<commit_after>var Query = require('../../classes/query');
var converter = require('../../classes/converter');

/**
 * get list of sesssions for user which are not finished.
 * @param {object} req - request object.
 * @param {object} res - response object.
 * @returns {array} - array with objects containing id and name of session
 */
exports.all = function(req, res) {
	var qstr = 'SELECT idsessions, name FROM sessions WHERE users_idusers = ' + req.params.user_id + ' AND finished = 0';

	var query = new Query;
	
	// TODO: session filter devices, apps 

	query.execute(qstr, '', function(rows) {
		res.send(rows);
	});
};

/**
 * get one session for user.
 * @param {object} req - request object.
 * @param {object} res - response object.
 *
 * @returns {object} - JSON object containing the session information
 */
exports.get = function(req, res) {
	
	console.log(req.params.session_id);
	
	var qstr = 'SELECT * FROM sessions WHERE users_idusers = ' + req.params.user_id + ' AND idsessions = ' + req.params.session_id;
	var query = new Query;
	
	query.execute(qstr, '', function(rows){
		res.send(rows);
	});
	
}

/**
 * updates a session.
 * @param {object} req - Request object
 * @param {object} res - Response object
 *
 */
exports.put = function(req, res) {
	
	// TODO check params 

	qstr = 'UPDATE sessions SET ';

	if( req.params.active != undefinded && req.params.active != '') { 
		// set active
		qstr += ' active = ' + req.params.active;
	} else if (req.params.name != undefined && req.params.name != '') { 
		// change name
		qstr += ' name = ' + req.params.name;
	} else if (req.params.finished != undefined) {
		// set finished
		
		// TODO  send 409 on finish not successfully
		// successfully is when logs and captures are already uploaded/added to the session. 
		qstr += ' name = ' + req.params.finished;
	}

	qstr += ' WHERE idsessions = ' + req.params.session_id; 

	// TODO error check
	query.execute(qstr, '', function(rows){
		// send to user
		res.send(rows);
	});

{'fraction_non_alphanumeric': 0.1519364448857994, 'fraction_numerical': 0.0019860973187686196, 'mean_word_length': 3.1578947368421053, 'pattern_counts': {'":': 0, '<': 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': '908320', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1240, 'n_words': 389}