<commit_before>var express = require('express');
var router = express.Router();
var dateDujour = require('../models/dateDujour');
var NbDeFruits = require('../models/NbDeFruits');

var Sequelize = require('sequelize');

var connection = new Sequelize('testsequelize', 'root', 'password');

/*
var fs = require('fs');
var obj;
fs.readFile('fruits.json', 'utf8', function (err, data) {
  if (err) throw err;
  obj = JSON.parse(data);
  kiwis = obj.fruits[0].kiwis;
  //console.log(kiwis);
});
*/

/* GET home page.*/
router.get('/', function (req, res, next) {
  res.render('index', dateDujour());
});

router.get('/test', function (req, res, next) {
  res.render('test', { title: 'youpidouo' });
});


router.get('/fruits', function (req, res, next) {
  connection.query("SELECT * FROM testsequelize.sensorvalues order by Sensors_SID;")
    .then(function (projects) {
      var array = []
      var init = projects[0][0].Sensors_SID
      var k = 0;
      var obj = {
        title: init,
        values: [{
          sensVal: projects[0][k].Value
        }]
      }
      //array.push(obj);
      for (var i = 1; i < projects[0].length - 1; i++) {
        if (init == projects[0][i].Sensors_SID) {
          //array.init.push({title: projects[0][0].Sensors_SID, sensVal: projects[0][0].Value});
          obj.values.push({ sensVal: projects[0][i].Value });
        }
        else {
          array[k] = obj;
          k++
          init = projects[0][i].Sensors_SID;
          var obj = {
            title: init,
            values: [{
              sensVal: projects[0][i].Value
            }]
          }
          //array.push(obj);
        }
      }
      res.render('fruits', {
        title: projects[0][0].Sensors_SID,
        sensId: projects[0][0].Sensors_SID,
        sensVal: projects[0][0].Value,
        sensors: projects[0]
      })
      // console.log("start-toto")
      console.log(projects)
      // console.log("end-toto")
    });
});

module.exports = router; <commit_msg>optimisation du tableau V1<commit_after>var express = require('express');
var router = express.Router();
var dateDujour = require('../models/dateDujour');
var NbDeFruits = require('../models/NbDeFruits');

var Sequelize = require('sequelize');

var connection = new Sequelize('testsequelize', 'root', 'password');

/*
var fs = require('fs');
var obj;
fs.readFile('fruits.json', 'utf8', function (err, data) {
  if (err) throw err;
  obj = JSON.parse(data);
  kiwis = obj.fruits[0].kiwis;
  //console.log(kiwis);
});
*/

/* GET home page.*/
router.get('/', function (req, res, next) {
  res.render('index', dateDujour());
});

router.get('/test', function (req, res, next) {
  res.render('test', { title: 'youpidouo' });
});


router.get('/fruits', function (req, res, next) {
  connection.query("SELECT * FROM testsequelize.sensorvalues order by Sensors_SID;")
    .then(function (projects) {
      var array = []
      var init = projects[0][0].Sensors_SID
      var k = 0;
      var obj = {
        title: init,
        values: [{
        sensVal: projects[0][0].Value
        }]
      }
      //array.push(obj);
      for (var i = 1; i < projects[0].length - 1; i++) {
        if (init == projects[0][i].Sensors_SID) {
          //array.init.push({title: projects[0][0].Sensors_SID, sensVal: projects[0][0].Value});
          obj.values.push({ sensVal: projects[0][i].Value });
          array[k] = obj;
        }
        else {
          k++
          init = projects[0][i].Sensors_SID;
          var obj = {
            title: init,
            values: [{
              sensVal: projects[0][i].Value
            }]
          }
          //array.push(obj);
        }
      }
      res.render('fruits', {
        title: projects[0][0].Sensors_SID,
        sensId: projects[0][0].Sensors_SID,
        sensVal: projects[0][0].Value,
        sensors: projects[0]
      })
      // console.log("start-toto")
      console.log(projects)
      // console.log("end-toto")
    });
});

module.exports = router; 
{'fraction_non_alphanumeric': 0.18345413646588352, 'fraction_numerical': 0.012496875781054736, 'mean_word_length': 2.3573825503355703, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2316502', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1355, 'n_words': 269}