1119 lines
28 KiB
JavaScript
1119 lines
28 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Cuestionarios = db.cuestionarios;
|
|
|
|
const Entrenadores = db.entrenadores;
|
|
|
|
const Miembros = db.miembros;
|
|
|
|
const PlanesEntrenamiento = db.planes_entrenamiento;
|
|
|
|
const PlanesNutricion = db.planes_nutricion;
|
|
|
|
const Progresos = db.progresos;
|
|
|
|
const Alumnos = db.alumnos;
|
|
|
|
const CuestionariosData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
preguntas: '¿Cuál es tu objetivo principal?',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
preguntas: '¿Tienes alguna lesión?',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
preguntas: '¿Cuántas veces a la semana entrenas?',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
preguntas: '¿Sigues alguna dieta especial?',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
preguntas: '¿Cuál es tu nivel de experiencia?',
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const EntrenadoresData = [
|
|
{
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
ganancias_mensuales: 1500,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
ganancias_mensuales: 2000,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
ganancias_mensuales: 1800,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
ganancias_mensuales: 2200,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
ganancias_mensuales: 1700,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const MiembrosData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_many" field
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const PlanesEntrenamientoData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
descripcion: 'Plan de fuerza',
|
|
|
|
fecha_inicio: new Date('2023-10-01T10:00:00Z'),
|
|
|
|
fecha_fin: new Date('2023-11-01T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
descripcion: 'Plan de resistencia',
|
|
|
|
fecha_inicio: new Date('2023-10-02T10:00:00Z'),
|
|
|
|
fecha_fin: new Date('2023-11-02T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
descripcion: 'Plan de flexibilidad',
|
|
|
|
fecha_inicio: new Date('2023-10-03T10:00:00Z'),
|
|
|
|
fecha_fin: new Date('2023-11-03T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
descripcion: 'Plan de cardio',
|
|
|
|
fecha_inicio: new Date('2023-10-04T10:00:00Z'),
|
|
|
|
fecha_fin: new Date('2023-11-04T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
descripcion: 'Plan de equilibrio',
|
|
|
|
fecha_inicio: new Date('2023-10-05T10:00:00Z'),
|
|
|
|
fecha_fin: new Date('2023-11-05T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const PlanesNutricionData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
descripcion: 'Dieta alta en proteínas',
|
|
|
|
fecha_inicio: new Date('2023-10-01T10:00:00Z'),
|
|
|
|
fecha_fin: new Date('2023-11-01T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
descripcion: 'Dieta baja en carbohidratos',
|
|
|
|
fecha_inicio: new Date('2023-10-02T10:00:00Z'),
|
|
|
|
fecha_fin: new Date('2023-11-02T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
descripcion: 'Dieta vegana',
|
|
|
|
fecha_inicio: new Date('2023-10-03T10:00:00Z'),
|
|
|
|
fecha_fin: new Date('2023-11-03T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
descripcion: 'Dieta mediterránea',
|
|
|
|
fecha_inicio: new Date('2023-10-04T10:00:00Z'),
|
|
|
|
fecha_fin: new Date('2023-11-04T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
descripcion: 'Dieta cetogénica',
|
|
|
|
fecha_inicio: new Date('2023-10-05T10:00:00Z'),
|
|
|
|
fecha_fin: new Date('2023-11-05T10:00:00Z'),
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ProgresosData = [
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
fecha: new Date('2023-10-01T10:00:00Z'),
|
|
|
|
porcentaje_cumplimiento: 85,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
fecha: new Date('2023-10-02T10:00:00Z'),
|
|
|
|
porcentaje_cumplimiento: 90,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
fecha: new Date('2023-10-03T10:00:00Z'),
|
|
|
|
porcentaje_cumplimiento: 75,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
fecha: new Date('2023-10-04T10:00:00Z'),
|
|
|
|
porcentaje_cumplimiento: 80,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
// type code here for "relation_one" field
|
|
|
|
fecha: new Date('2023-10-05T10:00:00Z'),
|
|
|
|
porcentaje_cumplimiento: 95,
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const AlumnosData = [
|
|
{
|
|
name: 'Christiaan Huygens',
|
|
},
|
|
|
|
{
|
|
name: 'Joseph J. Thomson',
|
|
},
|
|
|
|
{
|
|
name: 'Claude Bernard',
|
|
},
|
|
|
|
{
|
|
name: 'Anton van Leeuwenhoek',
|
|
},
|
|
|
|
{
|
|
name: 'Albrecht von Haller',
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateUserWithAlumno() {
|
|
const relatedAlumno0 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const User0 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (User0?.setAlumno) {
|
|
await User0.setAlumno(relatedAlumno0);
|
|
}
|
|
|
|
const relatedAlumno1 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const User1 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (User1?.setAlumno) {
|
|
await User1.setAlumno(relatedAlumno1);
|
|
}
|
|
|
|
const relatedAlumno2 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const User2 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (User2?.setAlumno) {
|
|
await User2.setAlumno(relatedAlumno2);
|
|
}
|
|
|
|
const relatedAlumno3 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const User3 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (User3?.setAlumno) {
|
|
await User3.setAlumno(relatedAlumno3);
|
|
}
|
|
|
|
const relatedAlumno4 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const User4 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (User4?.setAlumno) {
|
|
await User4.setAlumno(relatedAlumno4);
|
|
}
|
|
}
|
|
|
|
async function associateCuestionarioWithEntrenador() {
|
|
const relatedEntrenador0 = await Entrenadores.findOne({
|
|
offset: Math.floor(Math.random() * (await Entrenadores.count())),
|
|
});
|
|
const Cuestionario0 = await Cuestionarios.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Cuestionario0?.setEntrenador) {
|
|
await Cuestionario0.setEntrenador(relatedEntrenador0);
|
|
}
|
|
|
|
const relatedEntrenador1 = await Entrenadores.findOne({
|
|
offset: Math.floor(Math.random() * (await Entrenadores.count())),
|
|
});
|
|
const Cuestionario1 = await Cuestionarios.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Cuestionario1?.setEntrenador) {
|
|
await Cuestionario1.setEntrenador(relatedEntrenador1);
|
|
}
|
|
|
|
const relatedEntrenador2 = await Entrenadores.findOne({
|
|
offset: Math.floor(Math.random() * (await Entrenadores.count())),
|
|
});
|
|
const Cuestionario2 = await Cuestionarios.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Cuestionario2?.setEntrenador) {
|
|
await Cuestionario2.setEntrenador(relatedEntrenador2);
|
|
}
|
|
|
|
const relatedEntrenador3 = await Entrenadores.findOne({
|
|
offset: Math.floor(Math.random() * (await Entrenadores.count())),
|
|
});
|
|
const Cuestionario3 = await Cuestionarios.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Cuestionario3?.setEntrenador) {
|
|
await Cuestionario3.setEntrenador(relatedEntrenador3);
|
|
}
|
|
|
|
const relatedEntrenador4 = await Entrenadores.findOne({
|
|
offset: Math.floor(Math.random() * (await Entrenadores.count())),
|
|
});
|
|
const Cuestionario4 = await Cuestionarios.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Cuestionario4?.setEntrenador) {
|
|
await Cuestionario4.setEntrenador(relatedEntrenador4);
|
|
}
|
|
}
|
|
|
|
async function associateCuestionarioWithAlumno() {
|
|
const relatedAlumno0 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Cuestionario0 = await Cuestionarios.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Cuestionario0?.setAlumno) {
|
|
await Cuestionario0.setAlumno(relatedAlumno0);
|
|
}
|
|
|
|
const relatedAlumno1 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Cuestionario1 = await Cuestionarios.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Cuestionario1?.setAlumno) {
|
|
await Cuestionario1.setAlumno(relatedAlumno1);
|
|
}
|
|
|
|
const relatedAlumno2 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Cuestionario2 = await Cuestionarios.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Cuestionario2?.setAlumno) {
|
|
await Cuestionario2.setAlumno(relatedAlumno2);
|
|
}
|
|
|
|
const relatedAlumno3 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Cuestionario3 = await Cuestionarios.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Cuestionario3?.setAlumno) {
|
|
await Cuestionario3.setAlumno(relatedAlumno3);
|
|
}
|
|
|
|
const relatedAlumno4 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Cuestionario4 = await Cuestionarios.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Cuestionario4?.setAlumno) {
|
|
await Cuestionario4.setAlumno(relatedAlumno4);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateEntrenadoreWithAlumno() {
|
|
const relatedAlumno0 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Entrenadore0 = await Entrenadores.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Entrenadore0?.setAlumno) {
|
|
await Entrenadore0.setAlumno(relatedAlumno0);
|
|
}
|
|
|
|
const relatedAlumno1 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Entrenadore1 = await Entrenadores.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Entrenadore1?.setAlumno) {
|
|
await Entrenadore1.setAlumno(relatedAlumno1);
|
|
}
|
|
|
|
const relatedAlumno2 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Entrenadore2 = await Entrenadores.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Entrenadore2?.setAlumno) {
|
|
await Entrenadore2.setAlumno(relatedAlumno2);
|
|
}
|
|
|
|
const relatedAlumno3 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Entrenadore3 = await Entrenadores.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Entrenadore3?.setAlumno) {
|
|
await Entrenadore3.setAlumno(relatedAlumno3);
|
|
}
|
|
|
|
const relatedAlumno4 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Entrenadore4 = await Entrenadores.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Entrenadore4?.setAlumno) {
|
|
await Entrenadore4.setAlumno(relatedAlumno4);
|
|
}
|
|
}
|
|
|
|
async function associateMiembroWithEntrenador() {
|
|
const relatedEntrenador0 = await Entrenadores.findOne({
|
|
offset: Math.floor(Math.random() * (await Entrenadores.count())),
|
|
});
|
|
const Miembro0 = await Miembros.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Miembro0?.setEntrenador) {
|
|
await Miembro0.setEntrenador(relatedEntrenador0);
|
|
}
|
|
|
|
const relatedEntrenador1 = await Entrenadores.findOne({
|
|
offset: Math.floor(Math.random() * (await Entrenadores.count())),
|
|
});
|
|
const Miembro1 = await Miembros.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Miembro1?.setEntrenador) {
|
|
await Miembro1.setEntrenador(relatedEntrenador1);
|
|
}
|
|
|
|
const relatedEntrenador2 = await Entrenadores.findOne({
|
|
offset: Math.floor(Math.random() * (await Entrenadores.count())),
|
|
});
|
|
const Miembro2 = await Miembros.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Miembro2?.setEntrenador) {
|
|
await Miembro2.setEntrenador(relatedEntrenador2);
|
|
}
|
|
|
|
const relatedEntrenador3 = await Entrenadores.findOne({
|
|
offset: Math.floor(Math.random() * (await Entrenadores.count())),
|
|
});
|
|
const Miembro3 = await Miembros.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Miembro3?.setEntrenador) {
|
|
await Miembro3.setEntrenador(relatedEntrenador3);
|
|
}
|
|
|
|
const relatedEntrenador4 = await Entrenadores.findOne({
|
|
offset: Math.floor(Math.random() * (await Entrenadores.count())),
|
|
});
|
|
const Miembro4 = await Miembros.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Miembro4?.setEntrenador) {
|
|
await Miembro4.setEntrenador(relatedEntrenador4);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateMiembroWithAlumno() {
|
|
const relatedAlumno0 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Miembro0 = await Miembros.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Miembro0?.setAlumno) {
|
|
await Miembro0.setAlumno(relatedAlumno0);
|
|
}
|
|
|
|
const relatedAlumno1 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Miembro1 = await Miembros.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Miembro1?.setAlumno) {
|
|
await Miembro1.setAlumno(relatedAlumno1);
|
|
}
|
|
|
|
const relatedAlumno2 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Miembro2 = await Miembros.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Miembro2?.setAlumno) {
|
|
await Miembro2.setAlumno(relatedAlumno2);
|
|
}
|
|
|
|
const relatedAlumno3 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Miembro3 = await Miembros.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Miembro3?.setAlumno) {
|
|
await Miembro3.setAlumno(relatedAlumno3);
|
|
}
|
|
|
|
const relatedAlumno4 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Miembro4 = await Miembros.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Miembro4?.setAlumno) {
|
|
await Miembro4.setAlumno(relatedAlumno4);
|
|
}
|
|
}
|
|
|
|
async function associatePlanesEntrenamientoWithMiembro() {
|
|
const relatedMiembro0 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const PlanesEntrenamiento0 = await PlanesEntrenamiento.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (PlanesEntrenamiento0?.setMiembro) {
|
|
await PlanesEntrenamiento0.setMiembro(relatedMiembro0);
|
|
}
|
|
|
|
const relatedMiembro1 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const PlanesEntrenamiento1 = await PlanesEntrenamiento.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (PlanesEntrenamiento1?.setMiembro) {
|
|
await PlanesEntrenamiento1.setMiembro(relatedMiembro1);
|
|
}
|
|
|
|
const relatedMiembro2 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const PlanesEntrenamiento2 = await PlanesEntrenamiento.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (PlanesEntrenamiento2?.setMiembro) {
|
|
await PlanesEntrenamiento2.setMiembro(relatedMiembro2);
|
|
}
|
|
|
|
const relatedMiembro3 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const PlanesEntrenamiento3 = await PlanesEntrenamiento.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (PlanesEntrenamiento3?.setMiembro) {
|
|
await PlanesEntrenamiento3.setMiembro(relatedMiembro3);
|
|
}
|
|
|
|
const relatedMiembro4 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const PlanesEntrenamiento4 = await PlanesEntrenamiento.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (PlanesEntrenamiento4?.setMiembro) {
|
|
await PlanesEntrenamiento4.setMiembro(relatedMiembro4);
|
|
}
|
|
}
|
|
|
|
async function associatePlanesEntrenamientoWithAlumno() {
|
|
const relatedAlumno0 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const PlanesEntrenamiento0 = await PlanesEntrenamiento.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (PlanesEntrenamiento0?.setAlumno) {
|
|
await PlanesEntrenamiento0.setAlumno(relatedAlumno0);
|
|
}
|
|
|
|
const relatedAlumno1 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const PlanesEntrenamiento1 = await PlanesEntrenamiento.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (PlanesEntrenamiento1?.setAlumno) {
|
|
await PlanesEntrenamiento1.setAlumno(relatedAlumno1);
|
|
}
|
|
|
|
const relatedAlumno2 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const PlanesEntrenamiento2 = await PlanesEntrenamiento.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (PlanesEntrenamiento2?.setAlumno) {
|
|
await PlanesEntrenamiento2.setAlumno(relatedAlumno2);
|
|
}
|
|
|
|
const relatedAlumno3 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const PlanesEntrenamiento3 = await PlanesEntrenamiento.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (PlanesEntrenamiento3?.setAlumno) {
|
|
await PlanesEntrenamiento3.setAlumno(relatedAlumno3);
|
|
}
|
|
|
|
const relatedAlumno4 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const PlanesEntrenamiento4 = await PlanesEntrenamiento.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (PlanesEntrenamiento4?.setAlumno) {
|
|
await PlanesEntrenamiento4.setAlumno(relatedAlumno4);
|
|
}
|
|
}
|
|
|
|
async function associatePlanesNutricionWithMiembro() {
|
|
const relatedMiembro0 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const PlanesNutricion0 = await PlanesNutricion.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (PlanesNutricion0?.setMiembro) {
|
|
await PlanesNutricion0.setMiembro(relatedMiembro0);
|
|
}
|
|
|
|
const relatedMiembro1 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const PlanesNutricion1 = await PlanesNutricion.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (PlanesNutricion1?.setMiembro) {
|
|
await PlanesNutricion1.setMiembro(relatedMiembro1);
|
|
}
|
|
|
|
const relatedMiembro2 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const PlanesNutricion2 = await PlanesNutricion.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (PlanesNutricion2?.setMiembro) {
|
|
await PlanesNutricion2.setMiembro(relatedMiembro2);
|
|
}
|
|
|
|
const relatedMiembro3 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const PlanesNutricion3 = await PlanesNutricion.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (PlanesNutricion3?.setMiembro) {
|
|
await PlanesNutricion3.setMiembro(relatedMiembro3);
|
|
}
|
|
|
|
const relatedMiembro4 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const PlanesNutricion4 = await PlanesNutricion.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (PlanesNutricion4?.setMiembro) {
|
|
await PlanesNutricion4.setMiembro(relatedMiembro4);
|
|
}
|
|
}
|
|
|
|
async function associatePlanesNutricionWithAlumno() {
|
|
const relatedAlumno0 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const PlanesNutricion0 = await PlanesNutricion.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (PlanesNutricion0?.setAlumno) {
|
|
await PlanesNutricion0.setAlumno(relatedAlumno0);
|
|
}
|
|
|
|
const relatedAlumno1 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const PlanesNutricion1 = await PlanesNutricion.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (PlanesNutricion1?.setAlumno) {
|
|
await PlanesNutricion1.setAlumno(relatedAlumno1);
|
|
}
|
|
|
|
const relatedAlumno2 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const PlanesNutricion2 = await PlanesNutricion.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (PlanesNutricion2?.setAlumno) {
|
|
await PlanesNutricion2.setAlumno(relatedAlumno2);
|
|
}
|
|
|
|
const relatedAlumno3 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const PlanesNutricion3 = await PlanesNutricion.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (PlanesNutricion3?.setAlumno) {
|
|
await PlanesNutricion3.setAlumno(relatedAlumno3);
|
|
}
|
|
|
|
const relatedAlumno4 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const PlanesNutricion4 = await PlanesNutricion.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (PlanesNutricion4?.setAlumno) {
|
|
await PlanesNutricion4.setAlumno(relatedAlumno4);
|
|
}
|
|
}
|
|
|
|
async function associateProgresoWithMiembro() {
|
|
const relatedMiembro0 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const Progreso0 = await Progresos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Progreso0?.setMiembro) {
|
|
await Progreso0.setMiembro(relatedMiembro0);
|
|
}
|
|
|
|
const relatedMiembro1 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const Progreso1 = await Progresos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Progreso1?.setMiembro) {
|
|
await Progreso1.setMiembro(relatedMiembro1);
|
|
}
|
|
|
|
const relatedMiembro2 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const Progreso2 = await Progresos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Progreso2?.setMiembro) {
|
|
await Progreso2.setMiembro(relatedMiembro2);
|
|
}
|
|
|
|
const relatedMiembro3 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const Progreso3 = await Progresos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Progreso3?.setMiembro) {
|
|
await Progreso3.setMiembro(relatedMiembro3);
|
|
}
|
|
|
|
const relatedMiembro4 = await Miembros.findOne({
|
|
offset: Math.floor(Math.random() * (await Miembros.count())),
|
|
});
|
|
const Progreso4 = await Progresos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Progreso4?.setMiembro) {
|
|
await Progreso4.setMiembro(relatedMiembro4);
|
|
}
|
|
}
|
|
|
|
async function associateProgresoWithAlumno() {
|
|
const relatedAlumno0 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Progreso0 = await Progresos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Progreso0?.setAlumno) {
|
|
await Progreso0.setAlumno(relatedAlumno0);
|
|
}
|
|
|
|
const relatedAlumno1 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Progreso1 = await Progresos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Progreso1?.setAlumno) {
|
|
await Progreso1.setAlumno(relatedAlumno1);
|
|
}
|
|
|
|
const relatedAlumno2 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Progreso2 = await Progresos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Progreso2?.setAlumno) {
|
|
await Progreso2.setAlumno(relatedAlumno2);
|
|
}
|
|
|
|
const relatedAlumno3 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Progreso3 = await Progresos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Progreso3?.setAlumno) {
|
|
await Progreso3.setAlumno(relatedAlumno3);
|
|
}
|
|
|
|
const relatedAlumno4 = await Alumnos.findOne({
|
|
offset: Math.floor(Math.random() * (await Alumnos.count())),
|
|
});
|
|
const Progreso4 = await Progresos.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Progreso4?.setAlumno) {
|
|
await Progreso4.setAlumno(relatedAlumno4);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Cuestionarios.bulkCreate(CuestionariosData);
|
|
|
|
await Entrenadores.bulkCreate(EntrenadoresData);
|
|
|
|
await Miembros.bulkCreate(MiembrosData);
|
|
|
|
await PlanesEntrenamiento.bulkCreate(PlanesEntrenamientoData);
|
|
|
|
await PlanesNutricion.bulkCreate(PlanesNutricionData);
|
|
|
|
await Progresos.bulkCreate(ProgresosData);
|
|
|
|
await Alumnos.bulkCreate(AlumnosData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithAlumno(),
|
|
|
|
await associateCuestionarioWithEntrenador(),
|
|
|
|
await associateCuestionarioWithAlumno(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateEntrenadoreWithAlumno(),
|
|
|
|
await associateMiembroWithEntrenador(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateMiembroWithAlumno(),
|
|
|
|
await associatePlanesEntrenamientoWithMiembro(),
|
|
|
|
await associatePlanesEntrenamientoWithAlumno(),
|
|
|
|
await associatePlanesNutricionWithMiembro(),
|
|
|
|
await associatePlanesNutricionWithAlumno(),
|
|
|
|
await associateProgresoWithMiembro(),
|
|
|
|
await associateProgresoWithAlumno(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('cuestionarios', null, {});
|
|
|
|
await queryInterface.bulkDelete('entrenadores', null, {});
|
|
|
|
await queryInterface.bulkDelete('miembros', null, {});
|
|
|
|
await queryInterface.bulkDelete('planes_entrenamiento', null, {});
|
|
|
|
await queryInterface.bulkDelete('planes_nutricion', null, {});
|
|
|
|
await queryInterface.bulkDelete('progresos', null, {});
|
|
|
|
await queryInterface.bulkDelete('alumnos', null, {});
|
|
},
|
|
};
|