<commit_before>var path = require('path');

// Cargar Modelo ORM
var Sequelize = require('sequelize');

// Usar BBDD 
var url, storage;
if (!process.env.DATABASE_URL) {
  url = "sqlite:///";
  storage = "quiz.sqlite";
} else {
  url = process.env.DATABASE_URL;
  storage = process.env.DATABASE_STORAGE || "";
}
//var sequelize = new Sequelize(null, null, null, {
//  dialect: "sqlite",
//  storage: "quiz.sqlite"
//});
var sequelize = new Sequelize(url, {
  storage :storage,
  omitNull :true
});
// Importar la definicion de la tabla Users de user.js
var User = sequelize.import(path.join(__dirname, 'user'));

// Importar la definicion de la tabla Quiz de quiz.js
var Quiz = sequelize.import(path.join(__dirname, 'quiz'));


// sequelize.sync() crea e inicializa tabla de preguntas en DB
sequelize.sync().then(function() {
  return Quiz.count().then(function (c) {
    if (c === 0) { // la tabla se inicializa si está vacía 
      return Quiz.bulkCreate([
        { question: 'Capital de Italia', answer: 'Roma' },
        { question: 'Capital de Portugal', answer: 'Lisboa' },
        { question: 'Capital de Chechenia', answer: 'Grozni' }
              
      ]).then(function(){
        console.log('Base de datos inicializada con preguntas');
      });
    }
  });
}).catch(function(error){
  console.log("Error Sincronizando las tablas de la BBDD", error);
  process.exit(1);
});

sequelize.sync().then(function() {
  return User.count().then(function (c) {
    if (c === 0) { // la tabla se inicializa si está vacía 
      return User.bulkCreate([
        { username: 'admin', password: '<PASSWORD>', salt: 'tyrn', isAdmin: true },
        { username: 'oscar', password: '<PASSWORD>', salt: 'akqj', isAdmin: false }
      ]).then(function(){
        console.log('Base de usuarios inicializada');
      });
    }
  });
}).catch(function(error){<commit_msg>Tabla de Usuarios3<commit_after>var path = require('path');

// Cargar Modelo ORM
var Sequelize = require('sequelize');

// Usar BBDD 
var url, storage;
if (!process.env.DATABASE_URL) {
  url = "sqlite:///";
  storage = "quiz.sqlite";
} else {
  url = process.env.DATABASE_URL;
  storage = process.env.DATABASE_STORAGE || "";
}
//var sequelize = new Sequelize(null, null, null, {
//  dialect: "sqlite",
//  storage: "quiz.sqlite"
//});
var sequelize = new Sequelize(url, {
  storage :storage,
  omitNull :true
});
// Importar la definicion de la tabla Users de user.js
var User = sequelize.import(path.join(__dirname, 'user'));

// Importar la definicion de la tabla Quiz de quiz.js
var Quiz = sequelize.import(path.join(__dirname, 'quiz'));


// sequelize.sync() crea e inicializa tabla de preguntas en DB
sequelize.sync().then(function() {
  return Quiz.count().then(function (c) {
    if (c === 0) { // la tabla se inicializa si está vacía 
      return Quiz.bulkCreate([
        { question: 'Capital de Italia', answer: 'Roma' },
        { question: 'Capital de Portugal', answer: 'Lisboa' },
        { question: 'Capital de Chechenia', answer: 'Grozni' }
      ]).then(function(){
        console.log('Base de datos inicializada con preguntas');
      });
    }
  });
}).catch(function(error){
  console.log("Error Sincronizando las tablas de la BBDD", error);
  process.exit(1);
});

sequelize.sync().then(function() {
  return User.count().then(function (c) {
    if (c === 0) { // la tabla se inicializa si está vacía 
      return User.bulkCreate([
        { username: 'admin', password: '<PASSWORD>', salt: 'tyrn', isAdmin: true },
        { username: 'luis', password: '<PASSWORD>', salt: 'abcd', isAdmin: false }
      ]).then(function(){
        console.log('Base de usuarios inicializada');
      });
    }
  });
}).catch(function(error){
{'fraction_non_alphanumeric': 0.16635262449528937, 'fraction_numerical': 0.0018842530282637954, 'mean_word_length': 3.3209302325581396, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6562991', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1275, 'n_words': 335}