<commit_before>
/**
 * Module dependencies.
 //curl -i -X POST -H 'Content-Type: application/json' -d '{"Name": "MyFisrtexecution", "Description": "Testing ","other":"values","onemore":"please"}' http://localhost:3000/executions
 //curl -i -X POST -H 'Content-Type: application/json' -d '{"Name": "MyFisrtexecution", "Description": "Testing ","other":"values","onemore":"please"}' http://localhost:3000/execution/ID
 */

var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var app = express();
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
  host: 'localhost:9200',
  log: 'trace'
});

// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
//Change to html templates
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
//app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));

// development only
//if ('development' == app.get('env')) {
  app.use(express.errorHandler());
//}


app.get('/', routes.index);

//Just checking to see if the DB is up
app.get('/ping', function(req, res){
 		client.info("",function(err,resp){
 			if (err){
 				console.log(err);
 				res.send('No connection to ElasticSearch Cluster');
 			} else {
 				console.log(resp);
 				res.send(resp);
 			}
 		}); 		
});

//Searching for the list of all benchmarks
app.get('/executions', function(req, res){
	  client.search({index:'executions',size:10000},  function(err, result)
 		{
 			if (result.hits != undefined){
	  			var only_results = result.hits.hits;
	  			var es_result = [];
	  			var keys = Object.keys(only_results);

	  			keys.forEach(
	  				function(key)
	  					{
        				es_result.push(only_results[key]._source);
        				console.log("Adding "+key+" number to result ");
        				console.log(JSON.stringify(es_result[key]));
        			});
	  			res.send(es_result);		
	  		} else {
	  			res.send('No data in the DB');
	  		}
	  
	  })
});



//curl -i -X POST -H 'Content-Type: application/json' -d '{"Name":"Execution2","Description": "Testin filter timestamp","nodes":["node1","node2","node3"]}' http://localhost:3000/executions
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"1396622230","metric_1":"value1","metric_2":"value2","metric_3":"value3","metric_4":"value4"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"1396622231","metric_1":"value2","metric_2":"value2","metric_3":"value3","metric_4":"value5"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"1396622232","metric_1":"value4","metric_2":"value24","metric_3":"value34","metric_44":"value54"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"1396622233","metric_1":"value27","metric_2":"value27","metric_3":"value36","metric_4":"value56"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"1396622234","metric_1":"value2","metric_2":"value2","metric_3":"value3","metric_4":"value5"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"1396622240","metric_1":"value2","metric_2":"value2","metric_3":"value3","metric_4":"value5"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"13966222405","metric_1":"value2","metric_2":"value2","metric_3":"value3","metric_4":"value5"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
<commit_msg>Added id as first value for each array<commit_after>
/**
 * Module dependencies.
 //curl -i -X POST -H 'Content-Type: application/json' -d '{"Name": "MyFisrtexecution", "Description": "Testing ","other":"values","onemore":"please"}' http://localhost:3000/executions
 //curl -i -X POST -H 'Content-Type: application/json' -d '{"Name": "MyFisrtexecution", "Description": "Testing ","other":"values","onemore":"please"}' http://localhost:3000/execution/ID
 */

var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var app = express();
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
  host: 'localhost:9200',
  log: 'trace'
});

// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
//Change to html templates
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
//app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));

// development only
//if ('development' == app.get('env')) {
  app.use(express.errorHandler());
//}


app.get('/', routes.index);

//Just checking to see if the DB is up
app.get('/ping', function(req, res){
 		client.info("",function(err,resp){
 			if (err){
 				console.log(err);
 				res.send('No connection to ElasticSearch Cluster');
 			} else {
 				console.log(resp);
 				res.send(resp);
 			}
 		}); 		
});

//Searching for the list of all benchmarks
app.get('/executions', function(req, res){
	  client.search({index:'executions',size:10000},  function(err, result)
 		{
 			if (result.hits != undefined){
          
	  			var only_results = result.hits.hits;
        //  var all_hits = result.hits;
        //  var execution_ID = result.hits._id;
        //  console.log(execution_ID);
	  			var es_result = [];
	  			var keys = Object.keys(only_results);

	  			keys.forEach(
	  				function(key)
	  					{
        				es_result.push(only_results[key]._id);
                es_result.push(only_results[key]._source);
                console.log('{id:'+only_results[key]._id+",details:"+only_results[key]._source+"}");
        				console.log("Adding "+key+" number to result ");
        				console.log(JSON.stringify(es_result[key]));
                console.log("The ID for this one is "+only_results[key]._id+" \n")
        			});
	  			res.send(es_result);		
	  		} else {
	  			res.send('No data in the DB');
	  		}
	  
	  })
});



//curl -i -X POST -H 'Content-Type: application/json' -d '{"Name":"Execution2","Description": "Testin filter timestamp","nodes":["node1","node2","node3"]}' http://localhost:3000/executions
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"1396622230","metric_1":"value1","metric_2":"value2","metric_3":"value3","metric_4":"value4"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"1396622231","metric_1":"value2","metric_2":"value2","metric_3":"value3","metric_4":"value5"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"1396622232","metric_1":"value4","metric_2":"value24","metric_3":"value34","metric_44":"value54"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"1396622233","metric_1":"value27","metric_2":"value27","metric_3":"value36","metric_4":"value56"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"1396622234","metric_1":"value2","metric_2":"value2","metric_3":"value3","metric_4":"value5"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"1396622240","metric_1":"value2","metric_2":"value2","metric_3":"value3","metric_4":"value5"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ
//curl -i -X POST -H 'Content-Type: application/json' -d '{"Timestamp":"13966222405","metric_1":"value2","metric_2":"value2","metric_3":"value3","metric_4":"value5"}' http://localhost:3000/execution/o0Wuji4QRCaKVwDmbVzeNQ

{'fraction_non_alphanumeric': 0.20725508317929758, 'fraction_numerical': 0.047597042513863215, 'mean_word_length': 4.849324324324324, 'pattern_counts': {'":': 92, '<': 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': '2063226', 'n_tokens_mistral': 3383, 'n_tokens_neox': 2984, 'n_words': 518}