carrera dia hora
This commit is contained in:
@@ -2,6 +2,11 @@ const csv = require('csvtojson');
|
||||
const { Op } = require('sequelize');
|
||||
const dbPath = './db/tablas';
|
||||
const Carrera = require(`${dbPath}/Carrera`);
|
||||
const Dia = require(`${dbPath}/Dia`);
|
||||
const DiaHora = require(`${dbPath}/DiaHora`);
|
||||
const Grupo = require(`${dbPath}/Grupo`);
|
||||
const GrupoDiaHora = require(`${dbPath}/GrupoDiaHora`);
|
||||
const Hora = require(`${dbPath}/Hora`);
|
||||
const TercerSemestre = require(`${dbPath}/TercerSemestre`);
|
||||
|
||||
const cargaMasiva = async () => {
|
||||
@@ -9,7 +14,22 @@ const cargaMasiva = async () => {
|
||||
|
||||
await csv()
|
||||
.fromFile(path)
|
||||
.then(async (alumnos) => {});
|
||||
.then(async (alumnos) => {
|
||||
// for (let i = 0; i < alumnos.length; i++) {
|
||||
for (let i = 0; i < 1; i++) {
|
||||
await GrupoDiaHora.findOne({
|
||||
include: [
|
||||
{
|
||||
model: Grupo,
|
||||
include: [
|
||||
{ model: Carrera, where: { carrera: alumnos[i].carrera } },
|
||||
],
|
||||
},
|
||||
{ model: DiaHora, include: [{ model: Dia }, { model: Hora }] },
|
||||
],
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
cargaMasiva();
|
||||
|
||||
+136
-19
@@ -2,6 +2,7 @@ require('../config/config');
|
||||
const colors = require('colors');
|
||||
const { min } = require('./tablas/Carrera');
|
||||
const Carrera = require('./tablas/Carrera');
|
||||
const CarreraDiaHora = require('./tablas/CarreraDiaHora');
|
||||
const Dia = require('./tablas/Dia');
|
||||
const DiaHora = require('./tablas/DiaHora');
|
||||
const Grupo = require('./tablas/Grupo');
|
||||
@@ -22,6 +23,9 @@ const drop = async () => {
|
||||
await GrupoDiaHora.drop();
|
||||
console.log('La tabla GrupoDiaHora se desinstalo correctamente.'.magenta);
|
||||
|
||||
await CarreraDiaHora.drop();
|
||||
console.log('La tabla CarreraDiaHora se desinstalo correctamente.'.magenta);
|
||||
|
||||
await DiaHora.drop();
|
||||
console.log('La tabla DiaHora se desinstalo correctamente.'.magenta);
|
||||
|
||||
@@ -56,6 +60,9 @@ const sync = async () => {
|
||||
await DiaHora.sync();
|
||||
console.log('La tabla DiaHora se instalo correctamente.'.magenta);
|
||||
|
||||
await CarreraDiaHora.sync();
|
||||
console.log('La tabla CarreraDiaHora se instalo correctamente.'.magenta);
|
||||
|
||||
await GrupoDiaHora.sync();
|
||||
console.log('La tabla GrupoDiaHora se instalo correctamente.'.magenta);
|
||||
|
||||
@@ -67,61 +74,157 @@ const sync = async () => {
|
||||
};
|
||||
|
||||
const data = [
|
||||
{ carrera: 'ACTUARÍA', segundoMatutino: 4, segundoDespertino: 3 },
|
||||
{ carrera: 'ARQUITECTURA', segundoMatutino: 4, segundoDespertino: 3 },
|
||||
{
|
||||
carrera: 'ACTUARÍA',
|
||||
primeroMatutino: 4,
|
||||
primeroDespertino: 3,
|
||||
segundoMatutino: 4,
|
||||
segundoDespertino: 3,
|
||||
},
|
||||
{
|
||||
carrera: 'ARQUITECTURA',
|
||||
primeroMatutino: 4,
|
||||
primeroDespertino: 3,
|
||||
segundoMatutino: 4,
|
||||
segundoDespertino: 3,
|
||||
},
|
||||
{
|
||||
carrera: 'CIENCIAS POLÍTICAS Y ADMON. PÚBLICA',
|
||||
primeroMatutino: 3,
|
||||
primeroDespertino: 2,
|
||||
segundoMatutino: 3,
|
||||
segundoDespertino: 2,
|
||||
},
|
||||
{
|
||||
carrera: 'COMUNICACIÓN',
|
||||
primeroMatutino: 4,
|
||||
primeroDespertino: 4,
|
||||
segundoMatutino: 4,
|
||||
segundoDespertino: 4,
|
||||
},
|
||||
{
|
||||
carrera: 'DERECHO',
|
||||
primeroMatutino: 9,
|
||||
primeroDespertino: 9,
|
||||
segundoMatutino: 9,
|
||||
segundoDespertino: 9,
|
||||
},
|
||||
{
|
||||
carrera: 'DISEÑO GRÁFICO',
|
||||
primeroMatutino: 4,
|
||||
primeroDespertino: 4,
|
||||
segundoMatutino: 4,
|
||||
segundoDespertino: 4,
|
||||
},
|
||||
{
|
||||
carrera: 'ECONOMÍA',
|
||||
primeroMatutino: 3,
|
||||
primeroDespertino: 2,
|
||||
segundoMatutino: 3,
|
||||
segundoDespertino: 2,
|
||||
},
|
||||
{
|
||||
carrera: 'ENSEÑANZA DE INGLÉS',
|
||||
primeroMatutino: 1,
|
||||
primeroDespertino: 1,
|
||||
segundoMatutino: 1,
|
||||
segundoDespertino: 1,
|
||||
},
|
||||
{
|
||||
carrera: 'FILOSOFÍA',
|
||||
primeroMatutino: 1,
|
||||
primeroDespertino: 1,
|
||||
segundoMatutino: 1,
|
||||
segundoDespertino: 1,
|
||||
},
|
||||
{
|
||||
carrera: 'HISTORIA',
|
||||
primeroMatutino: 2,
|
||||
primeroDespertino: 1,
|
||||
segundoMatutino: 2,
|
||||
segundoDespertino: 1,
|
||||
},
|
||||
{
|
||||
carrera: 'INGENIERÍA CIVIL',
|
||||
primeroMatutino: 3,
|
||||
primeroDespertino: 2,
|
||||
segundoMatutino: 3,
|
||||
segundoDespertino: 2,
|
||||
},
|
||||
{ carrera: 'COMUNICACIÓN', segundoMatutino: 4, segundoDespertino: 4 },
|
||||
{ carrera: 'DERECHO', segundoMatutino: 9, segundoDespertino: 9 },
|
||||
{ carrera: 'DISEÑO GRÁFICO', segundoMatutino: 4, segundoDespertino: 4 },
|
||||
{ carrera: 'ECONOMÍA', segundoMatutino: 3, segundoDespertino: 2 },
|
||||
{ carrera: 'ENSEÑANZA DE INGLÉS', segundoMatutino: 1, segundoDespertino: 1 },
|
||||
{ carrera: 'FILOSOFÍA', segundoMatutino: 1, segundoDespertino: 1 },
|
||||
{ carrera: 'HISTORIA', segundoMatutino: 2, segundoDespertino: 1 },
|
||||
{ carrera: 'INGENIERÍA CIVIL', segundoMatutino: 3, segundoDespertino: 2 },
|
||||
{
|
||||
carrera: 'LENGUA Y LITERATURA HISPÁNICAS',
|
||||
primeroMatutino: 1,
|
||||
primeroDespertino: 1,
|
||||
segundoMatutino: 1,
|
||||
segundoDespertino: 1,
|
||||
},
|
||||
{
|
||||
carrera: 'MATEMÁTICAS. APL. Y COMP. (1999)',
|
||||
primeroMatutino: 4,
|
||||
primeroDespertino: 4,
|
||||
segundoMatutino: 4,
|
||||
segundoDespertino: 4,
|
||||
},
|
||||
{ carrera: 'PEDAGOGÍA', segundoMatutino: 4, segundoDespertino: 2 },
|
||||
{
|
||||
carrera: 'PEDAGOGÍA',
|
||||
primeroMatutino: 4,
|
||||
primeroDespertino: 2,
|
||||
segundoMatutino: 4,
|
||||
segundoDespertino: 2,
|
||||
},
|
||||
{
|
||||
carrera: 'RELACIONES INTERNACIONALES',
|
||||
primeroMatutino: 3,
|
||||
primeroDespertino: 3,
|
||||
segundoMatutino: 3,
|
||||
segundoDespertino: 3,
|
||||
},
|
||||
{ carrera: 'SOCIOLOGÍA', segundoMatutino: 2, segundoDespertino: 2 },
|
||||
// { carrera: 'DERECHO (SUA)', segundoMatutino: 0, segundoDespertino: 0 },
|
||||
{
|
||||
carrera: 'SOCIOLOGÍA',
|
||||
primeroMatutino: 2,
|
||||
primeroDespertino: 2,
|
||||
segundoMatutino: 2,
|
||||
segundoDespertino: 2,
|
||||
},
|
||||
// {
|
||||
// carrera: 'DERECHO (SUA)',
|
||||
// primeroMatutino: 0,
|
||||
// primeroDespertino: 0,
|
||||
// segundoMatutino: 0,
|
||||
// segundoDespertino: 0,
|
||||
// },
|
||||
// {
|
||||
// carrera: 'ENSEÑANZA DE ESPAÑOL(LENG EXTRANJERA)SUA',
|
||||
// primeroMatutino: 0,
|
||||
// primeroDespertino: 0,
|
||||
// segundoMatutino: 0,
|
||||
// segundoDespertino: 0,
|
||||
// },
|
||||
// {
|
||||
// carrera: 'ENSEÑANZA DE FRANCES(LENG EXTRANJERA)SUA',
|
||||
// primeroMatutino: 0,
|
||||
// primeroDespertino: 0,
|
||||
// segundoMatutino: 0,
|
||||
// segundoDespertino: 0,
|
||||
// },
|
||||
// {
|
||||
// carrera: 'ENSEÑANZA DE INGLES (LENG EXTRANJERA)SUA',
|
||||
// primeroMatutino: 0,
|
||||
// primeroDespertino: 0,
|
||||
// segundoMatutino: 0,
|
||||
// segundoDespertino: 0,
|
||||
// },
|
||||
// {
|
||||
// carrera: 'ENSEÑANZA DE ITALIANO(LENG EXTRANJ.)SUA',
|
||||
// primeroMatutino: 0,
|
||||
// primeroDespertino: 0,
|
||||
// segundoMatutino: 0,
|
||||
// segundoDespertino: 0,
|
||||
// },
|
||||
// {
|
||||
// carrera: 'RELACIONES INTERNACIONALES (SUA)',
|
||||
// primeroMatutino: 0,
|
||||
// primeroDespertino: 0,
|
||||
// segundoMatutino: 0,
|
||||
// segundoDespertino: 0,
|
||||
// },
|
||||
@@ -140,12 +243,28 @@ const dataCarrera = async () => {
|
||||
const dataGrupo = async () => {
|
||||
console.log('\nPaso 4) Instalando catalogo Grupo.'.bold.blue);
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
for (let j = 1; j <= data[i].primeroMatutino; j++) {
|
||||
const grupo = `110${j}`;
|
||||
|
||||
await Grupo.create({ grupo, idCarrera: i + 1 });
|
||||
console.log(
|
||||
`Se agrego el grupo ${grupo} a la carrera ${data[i].carrera} correctamente.`
|
||||
.magenta
|
||||
);
|
||||
}
|
||||
for (let j = 1; j <= data[i].primeroDespertino; j++) {
|
||||
const grupo = `115${j}`;
|
||||
|
||||
await Grupo.create({ grupo, idCarrera: i + 1 });
|
||||
console.log(
|
||||
`Se agrego el grupo ${grupo} a la carrera ${data[i].carrera} correctamente.`
|
||||
.magenta
|
||||
);
|
||||
}
|
||||
for (let j = 1; j <= data[i].segundoMatutino; j++) {
|
||||
const grupo = `220${j}`;
|
||||
|
||||
await Grupo.create({ grupo, idCarrera: i + 1 }).catch((err) => {
|
||||
console.log('hola', err);
|
||||
});
|
||||
await Grupo.create({ grupo, idCarrera: i + 1 });
|
||||
console.log(
|
||||
`Se agrego el grupo ${grupo} a la carrera ${data[i].carrera} correctamente.`
|
||||
.magenta
|
||||
@@ -154,9 +273,7 @@ const dataGrupo = async () => {
|
||||
for (let j = 1; j <= data[i].segundoDespertino; j++) {
|
||||
const grupo = `225${j}`;
|
||||
|
||||
await Grupo.create({ grupo, idCarrera: i + 1 }).catch((err) => {
|
||||
console.log('hola', err);
|
||||
});
|
||||
await Grupo.create({ grupo, idCarrera: i + 1 });
|
||||
console.log(
|
||||
`Se agrego el grupo ${grupo} a la carrera ${data[i].carrera} correctamente.`
|
||||
.magenta
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
const { DataTypes, Model } = require('sequelize');
|
||||
const sequelize = require('../../config/sequelize.conf');
|
||||
const Carrera = require('./Carrera');
|
||||
const DiaHora = require('./DiaHora');
|
||||
|
||||
class CarreraDiaHora extends Model {}
|
||||
CarreraDiaHora.init(
|
||||
{
|
||||
idCarreraDiaHora: {
|
||||
type: DataTypes.INTEGER,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
autoIncrement: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
sequelize,
|
||||
modelName: 'CarreraDiaHora',
|
||||
tableName: 'carrera_dia_hora',
|
||||
timestamps: false,
|
||||
}
|
||||
);
|
||||
|
||||
CarreraDiaHora.belongsTo(DiaHora, {
|
||||
foreignKey: {
|
||||
name: 'idDiaHora',
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
});
|
||||
|
||||
CarreraDiaHora.belongsTo(Carrera, {
|
||||
foreignKey: {
|
||||
name: 'idCarrera',
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
});
|
||||
|
||||
module.exports = CarreraDiaHora;
|
||||
@@ -1,7 +1,7 @@
|
||||
const { DataTypes, Model } = require('sequelize');
|
||||
const sequelize = require('../../config/sequelize.conf');
|
||||
const Grupo = require('./Grupo');
|
||||
const DiaHora = require('./DiaHora');
|
||||
const Grupo = require('./Grupo');
|
||||
|
||||
class PrimerSemestre extends Model {}
|
||||
PrimerSemestre.init(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const { DataTypes, Model } = require('sequelize');
|
||||
const sequelize = require('../../config/sequelize.conf');
|
||||
const GrupoDiaHora = require('./GrupoDiaHora');
|
||||
const Grupo = require('./Grupo');
|
||||
|
||||
class TercerSemestre extends Model {}
|
||||
TercerSemestre.init(
|
||||
@@ -35,9 +35,9 @@ TercerSemestre.init(
|
||||
}
|
||||
);
|
||||
|
||||
TercerSemestre.belongsTo(GrupoDiaHora, {
|
||||
TercerSemestre.belongsTo(Grupo, {
|
||||
foreignKey: {
|
||||
name: 'idGrupoDiaHora',
|
||||
name: 'idGrupo',
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user