Improvements added.
This commit is contained in:
+64
-19
@@ -15,6 +15,7 @@ faker.locale = "es_MX";
|
||||
|
||||
const colors = require('colors');
|
||||
const symbols = require('log-symbols');
|
||||
const progress = require('cli-progress');
|
||||
|
||||
let rows = 10;
|
||||
let faileds = 0;
|
||||
@@ -22,6 +23,27 @@ let ok = 0;
|
||||
let censo = 0;
|
||||
|
||||
async function fillingEquipo() {
|
||||
let count = 1;
|
||||
let barinventario = new progress.SingleBar({
|
||||
format: 'inventario [' + colors.cyan('{bar}') + '] {percentage}%' + '|| {value}/{total} records created.',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true,
|
||||
stopOnComplete: true,
|
||||
barsize: 30,
|
||||
align: 'right'
|
||||
});
|
||||
let barequipo = new progress.SingleBar({
|
||||
format: 'equipo [' + colors.cyan('{bar}') + '] {percentage}%' + '|| {value}/{total} records created.',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true,
|
||||
stopOnComplete: true,
|
||||
barsize: 30,
|
||||
align: 'right'
|
||||
});
|
||||
barinventario.start(rows, 0);
|
||||
barequipo.start(rows, 0);
|
||||
for (let i = 0; i < rows; i++) {
|
||||
let noInventario = faker.phone.phoneNumber("2######");
|
||||
let idActivoFijo = idUso = faker.random.number({
|
||||
@@ -31,42 +53,64 @@ async function fillingEquipo() {
|
||||
|
||||
// await fillDA();
|
||||
await fillInventario(noInventario, idActivoFijo)
|
||||
.then(() => {
|
||||
console.log(`${ i + 1 }/${ rows } records created on inventario-equipo`);
|
||||
censo++;
|
||||
})
|
||||
.catch((e) => {
|
||||
throw new Error(e);
|
||||
.then(() => censo++)
|
||||
.catch(() => {
|
||||
console.log(symbols.warning, 'Error creating «inventario-equipo»');
|
||||
barinventario.stop();
|
||||
throw new Error();
|
||||
});
|
||||
await fillEquipo(noInventario, idActivoFijo)
|
||||
.then(() => {
|
||||
console.log(`${ i + 1 }/${ rows } records created on equipo`);
|
||||
censo++;
|
||||
})
|
||||
.catch((e) => {
|
||||
throw new Error(e);
|
||||
.catch(() => {
|
||||
console.log(symbols.warning, 'Error creating «equipo»');
|
||||
barequipo.stop();
|
||||
throw new Error();
|
||||
});
|
||||
barinventario.increment();
|
||||
barequipo.increment();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
async function fillingPrinters() {
|
||||
for (let i = 0; i < rows; i++) {
|
||||
let pInventario = new progress.SingleBar({
|
||||
format: 'inventario [' + colors.cyan('{bar}') + '] {percentage}%' + '|| {value}/{total} records created.',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true,
|
||||
stopOnComplete: true,
|
||||
barsize: 30,
|
||||
align: 'right'
|
||||
});
|
||||
let barprinters = new progress.SingleBar({
|
||||
format: 'printers [' + colors.cyan('{bar}') + '] {percentage}%' + '|| {value}/{total} records created.',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true,
|
||||
stopOnComplete: true,
|
||||
barsize: 30,
|
||||
align: 'right'
|
||||
});
|
||||
pInventario.start(rows, 0);
|
||||
barprinters.start(rows, 0);
|
||||
for (let i = 1; i <= rows; i++) {
|
||||
let noInventario = faker.phone.phoneNumber("2######");
|
||||
let idActivoFijo = 6;
|
||||
|
||||
await fillInventario(noInventario, idActivoFijo)
|
||||
.then(() => console.log(`${ i + 1 }/${ rows } records created on inventario-printers`))
|
||||
.catch((e) => {
|
||||
.then(() => censo++)
|
||||
.catch(() => {
|
||||
console.log(symbols.warning, 'Error creating «inventario-printers»');
|
||||
throw new Error(e);
|
||||
pInventario.stop();
|
||||
throw new Error();
|
||||
});
|
||||
await fillPrinters(noInventario)
|
||||
.then(() => console.log(`${ i + 1 }/${ rows } records created on printers`))
|
||||
.catch((e) => {
|
||||
.catch(() => {
|
||||
console.log(symbols.warning, 'Error creating «printers»');
|
||||
throw new Error(e);
|
||||
barprinters.stop();
|
||||
throw new Error();
|
||||
});
|
||||
pInventario.increment();
|
||||
barprinters.increment();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -78,6 +122,7 @@ async function exec() {
|
||||
ok++;
|
||||
})
|
||||
.catch(() => {
|
||||
// console.log('\n');
|
||||
console.log(symbols.warning, 'Error creating «activoFijo».'.yellow.bold);
|
||||
faileds++;
|
||||
});
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
const ActivoFijo = require('../../server/models/tablas/ActivoFijo');
|
||||
const progress = require('cli-progress');
|
||||
const colors = require('colors');
|
||||
|
||||
async function fillActivoFijo() {
|
||||
let limit = 6;
|
||||
|
||||
const bar = new progress.SingleBar({
|
||||
format: 'activoFijo |' + colors.cyan('{bar}') + '| {percentage}%' + ' || {value}/{total} records created.',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true,
|
||||
stopOnComplete: true,
|
||||
barsize: 30,
|
||||
align: 'right'
|
||||
});
|
||||
|
||||
console.log('\n\tFilling out «activoFijo».'.cyan.italic.bold);
|
||||
|
||||
let af = [
|
||||
"PC",
|
||||
"Laptop",
|
||||
@@ -10,22 +25,21 @@ async function fillActivoFijo() {
|
||||
"Chromebook",
|
||||
"Impresora"
|
||||
];
|
||||
let count = 1;
|
||||
let limit = 6;
|
||||
|
||||
bar.start(limit, 0);
|
||||
for (activoFijo of af) {
|
||||
await ActivoFijo.create({
|
||||
activoFijo
|
||||
})
|
||||
.then(() => {
|
||||
console.log(`${ count }/${ limit }\trecords created.`);
|
||||
count++;
|
||||
// console.log(`${ count }/${ limit }\trecords created.`);
|
||||
})
|
||||
.catch(() => {
|
||||
bar.stop();
|
||||
throw new Error()
|
||||
});
|
||||
bar.increment();
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
module.exports = fillActivoFijo;
|
||||
@@ -49,8 +49,6 @@ async function fillEquipo(noInventario, idActivoFijo) {
|
||||
precision: 2
|
||||
});
|
||||
|
||||
// console.log("Modelo: ", modelo, "\nNúmero de serie: ", noSerie, "\nProcesador: ", procesador, "\nVelocidad de procesador: ", vProcesador, "\nMemoria: ", memoria, "\nCantidad de memoria: ", memoriasz, "\nVelocidad de memoria: ", vMemoria, "\nGráficos: ", graficos, "\nTamaño de almacenamiento: ", hdd);
|
||||
|
||||
await Equipo.create({
|
||||
modelo,
|
||||
noSerie,
|
||||
@@ -67,10 +65,6 @@ async function fillEquipo(noInventario, idActivoFijo) {
|
||||
// idDescripcion
|
||||
// idActivoFijo
|
||||
})
|
||||
.then(() => {
|
||||
// console.log(`${ count }/${ limit }\trecords created.`);
|
||||
// count++;
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error();
|
||||
});
|
||||
|
||||
+16
-3
@@ -1,8 +1,19 @@
|
||||
const Marca = require('../../server/models/tablas/Marca');
|
||||
const progress = require('cli-progress');
|
||||
const colors = require('colors');
|
||||
|
||||
async function fillMarca() {
|
||||
let count = 1;
|
||||
let limit = 11;
|
||||
const bar = new progress.SingleBar({
|
||||
format: 'marca |' + colors.cyan('{bar}') + '| {percentage}%' + ' || {value}/{total} records created.',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true,
|
||||
stopOnComplete: true,
|
||||
barsize: 30,
|
||||
align: 'right'
|
||||
});
|
||||
|
||||
let marcas = [
|
||||
"HP",
|
||||
"ECOIN",
|
||||
@@ -19,17 +30,19 @@ async function fillMarca() {
|
||||
|
||||
console.log('\n\tFilling out «marca».'.cyan.italic.bold);
|
||||
|
||||
bar.start(limit, 0);
|
||||
for (marca of marcas) {
|
||||
await Marca.create({
|
||||
marca
|
||||
})
|
||||
.then(() => {
|
||||
console.log(`${ count }/${ limit }\trecords created.`);
|
||||
count++;
|
||||
// console.log(`${ count }/${ limit }\trecords created.`);
|
||||
})
|
||||
.catch(() => {
|
||||
bar.stop();
|
||||
throw new Error();
|
||||
});
|
||||
bar.increment();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
+14
-5
@@ -1,8 +1,18 @@
|
||||
const OS = require('../../server/models/tablas/OS');
|
||||
const colors = require('colors');
|
||||
const progress = require('cli-progress');
|
||||
|
||||
async function fillOS() {
|
||||
let count = 1;
|
||||
let limit = 7;
|
||||
const bar = new progress.SingleBar({
|
||||
format: 'OS |' + colors.cyan('{bar}') + '| {percentage}%' + ' || {value}/{total} records created.',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true,
|
||||
stopOnComplete: true,
|
||||
barsize: 30,
|
||||
align: 'right'
|
||||
});
|
||||
let sistemas = [
|
||||
"Windows 7",
|
||||
"Windows 10",
|
||||
@@ -15,17 +25,16 @@ async function fillOS() {
|
||||
|
||||
console.log('\n\tFilling out «OS».'.cyan.italic.bold);
|
||||
|
||||
bar.start(limit, 0);
|
||||
for (osname of sistemas) {
|
||||
await OS.create({
|
||||
osname
|
||||
})
|
||||
.then(() => {
|
||||
console.log(`${ count }/${ limit }\trecords created.`);
|
||||
count++;
|
||||
})
|
||||
.catch(() => {
|
||||
bar.stop();
|
||||
throw new Error();
|
||||
});
|
||||
bar.increment();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
+18
-5
@@ -1,8 +1,18 @@
|
||||
const Tipo = require('../../server/models/tablas/Tipo');
|
||||
const progress = require('cli-progress');
|
||||
const colors = require('colors');
|
||||
|
||||
async function fillTipo() {
|
||||
let count = 1;
|
||||
let limit = 4;
|
||||
const bar = new progress.SingleBar({
|
||||
format: 'tipo |' + colors.cyan('{bar}') + '| {percentage}%' + ' || {value}/{total} records created.',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true,
|
||||
stopOnComplete: true,
|
||||
barsize: 30,
|
||||
align: 'right'
|
||||
});
|
||||
let tipos = [
|
||||
"Impresora",
|
||||
"Multifuncional",
|
||||
@@ -12,17 +22,20 @@ async function fillTipo() {
|
||||
|
||||
console.log('\n\tFilling out «tipo».'.cyan.italic.bold);
|
||||
|
||||
bar.start(limit, 0);
|
||||
for (tipo of tipos) {
|
||||
await Tipo.create({
|
||||
tipo
|
||||
})
|
||||
.then(() => {
|
||||
console.log(`${ count }/${ limit }\trecords created.`);
|
||||
count++;
|
||||
})
|
||||
// .then(() => {
|
||||
// console.log(`${ count }/${ limit }\trecords created.`);
|
||||
// count++;
|
||||
// })
|
||||
.catch(() => {
|
||||
bar.stop();
|
||||
throw new Error();
|
||||
});
|
||||
bar.increment();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
const UResponsable = require('../../server/models/tablas/UResponsable');
|
||||
const progress = require('cli-progress');
|
||||
const colors = require('colors');
|
||||
|
||||
const faker = require('faker');
|
||||
faker.locale = 'es_MX';
|
||||
@@ -6,9 +8,20 @@ faker.locale = 'es_MX';
|
||||
async function fillUResponsable() {
|
||||
let unidades = require('./unidades.json');
|
||||
let nombreResponsable = '';
|
||||
let limit = unidades.length;
|
||||
const bar = new progress.SingleBar({
|
||||
format: 'uResponsable |' + colors.cyan('{bar}') + '| {percentage}%' + ' || {value}/{total} records created.',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true,
|
||||
stopOnComplete: true,
|
||||
barsize: 30,
|
||||
align: 'right'
|
||||
});
|
||||
|
||||
console.log(`\n\tFilling out with ${ unidades.length } records on uResponsable, please wait...`.cyan.italic.bold);
|
||||
console.log(`\n\tFilling out with ${ limit } records on uResponsable, please wait...`.cyan.italic.bold);
|
||||
|
||||
bar.start(limit, 0);
|
||||
for (uResponsable of unidades) {
|
||||
nombreResponsable = faker.name.findName();
|
||||
await UResponsable.create({
|
||||
@@ -16,10 +29,12 @@ async function fillUResponsable() {
|
||||
nombreResponsable
|
||||
})
|
||||
.catch(() => {
|
||||
bar.stop();
|
||||
throw new Error();
|
||||
});
|
||||
bar.increment();
|
||||
};
|
||||
return unidades.length;
|
||||
return limit;
|
||||
};
|
||||
|
||||
module.exports = fillUResponsable;
|
||||
@@ -1,26 +1,35 @@
|
||||
const Ubicacion = require('../../server/models/tablas/Ubicacion');
|
||||
const progress = require('cli-progress');
|
||||
const colors = require('colors');
|
||||
|
||||
const faker = require('faker');
|
||||
faker.locale = "es_MX";
|
||||
|
||||
async function fillUbicacion() {
|
||||
let ubicaciones = require('./ubicaciones');
|
||||
let count = 1;
|
||||
let limit = 15;
|
||||
const bar = new progress.SingleBar({
|
||||
format: 'ubicacion |' + colors.cyan('{bar}') + '| {percentage}%' + ' || {value}/{total} records created.',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true,
|
||||
stopOnComplete: true,
|
||||
barsize: 30,
|
||||
align: 'right'
|
||||
});
|
||||
|
||||
console.log('\n\tFilling out «ubicacion».'.cyan.italic.bold);
|
||||
|
||||
bar.start(limit, 0);
|
||||
for (ubicacion of ubicaciones) {
|
||||
await Ubicacion.create({
|
||||
ubicacion
|
||||
})
|
||||
.then(() => {
|
||||
console.log(`${ count }/${ limit }\trecords created.`);
|
||||
count++;
|
||||
})
|
||||
.catch(() => {
|
||||
bar.stop();
|
||||
throw new Error();
|
||||
});
|
||||
bar.increment();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
+14
-5
@@ -1,24 +1,33 @@
|
||||
const Uso = require('../../server/models/tablas/Uso');
|
||||
const progress = require('cli-progress');
|
||||
const colors = require('colors');
|
||||
|
||||
async function fillUso() {
|
||||
let usos = require('./usos.json');
|
||||
|
||||
let count = 1;
|
||||
let limit = 6;
|
||||
const bar = new progress.SingleBar({
|
||||
format: 'uso |' + colors.cyan('{bar}') + '| {percentage}%' + ' || {value}/{total} records created.',
|
||||
barCompleteChar: '\u2588',
|
||||
barIncompleteChar: '\u2591',
|
||||
hideCursor: true,
|
||||
stopOnComplete: true,
|
||||
barsize: 30,
|
||||
align: 'right'
|
||||
});
|
||||
|
||||
console.log('\n\tFilling out «uso».'.cyan.italic.bold);
|
||||
|
||||
bar.start(limit, 0);
|
||||
for (uso of usos) {
|
||||
await Uso.create({
|
||||
uso
|
||||
})
|
||||
.then(() => {
|
||||
console.log(`${ count }/${ limit }\trecords created.`);
|
||||
count++;
|
||||
})
|
||||
.catch(() => {
|
||||
bar.stop();
|
||||
throw new Error();
|
||||
});
|
||||
bar.increment();
|
||||
};
|
||||
}
|
||||
module.exports = fillUso;
|
||||
Generated
+50
@@ -387,6 +387,56 @@
|
||||
"integrity": "sha512-gpaBrMAizVEANOpfZp/EEUixTXDyGt7DFzdK5hU+UbWt/J0lB0w20ncZj59Z9a93xHb9u12zF5BS6i9RKbtg4w==",
|
||||
"dev": true
|
||||
},
|
||||
"cli-progress": {
|
||||
"version": "3.8.2",
|
||||
"resolved": "https://registry.npmjs.org/cli-progress/-/cli-progress-3.8.2.tgz",
|
||||
"integrity": "sha512-qRwBxLldMSfxB+YGFgNRaj5vyyHe1yMpVeDL79c+7puGujdKJHQHydgqXDcrkvQgJ5U/d3lpf6vffSoVVUftVQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"colors": "^1.1.2",
|
||||
"string-width": "^4.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ansi-regex": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz",
|
||||
"integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==",
|
||||
"dev": true
|
||||
},
|
||||
"emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
|
||||
"dev": true
|
||||
},
|
||||
"is-fullwidth-code-point": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
|
||||
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
|
||||
"dev": true
|
||||
},
|
||||
"string-width": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",
|
||||
"integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"emoji-regex": "^8.0.0",
|
||||
"is-fullwidth-code-point": "^3.0.0",
|
||||
"strip-ansi": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"strip-ansi": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz",
|
||||
"integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^5.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"clone-response": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/clone-response/-/clone-response-1.0.2.tgz",
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"sequelize": "^6.3.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cli-progress": "^3.8.2",
|
||||
"faker": "^5.1.0",
|
||||
"generate-password": "^1.5.1",
|
||||
"gmail-send": "^1.8.10",
|
||||
|
||||
@@ -3,18 +3,19 @@ const Sequelize = require("sequelize");
|
||||
require("./config");
|
||||
|
||||
const sequelize = new Sequelize(
|
||||
process.env.DB,
|
||||
process.env.USERDB,
|
||||
process.env.PASSDB,
|
||||
{
|
||||
host: process.env.HOSTDB,
|
||||
dialect: process.env.TYPEDB,
|
||||
logging: false,
|
||||
dialectOptions: {
|
||||
useUTC: false //for reading from database
|
||||
},
|
||||
timezone: "-05:00" //for writing to database
|
||||
}
|
||||
process.env.DB,
|
||||
process.env.USERDB,
|
||||
process.env.PASSDB, {
|
||||
host: process.env.HOSTDB,
|
||||
dialect: process.env.TYPEDB,
|
||||
logging: false,
|
||||
dialectOptions: {
|
||||
useUTC: false, //for reading from database
|
||||
timezone: "Etc/GMT+5" //for writing to database
|
||||
},
|
||||
// timezone: "-05:00" //for writing to database
|
||||
timezone: "Etc/GMT+5" //for writing to database
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = sequelize;
|
||||
module.exports = sequelize;
|
||||
Reference in New Issue
Block a user