✅ FASE 3 COMPLETADA: Torneos y Ligas
Implementados 3 módulos con agent swarm: 1. SISTEMA DE TORNEOS - Tipos: Eliminación, Round Robin, Suizo, Consolación - Categorías: Masculina, Femenina, Mixta - Inscripciones con validación de niveles - Gestión de pagos y estados 2. CUADROS Y PARTIDOS - Generación automática de cuadros - Algoritmos: Circle method (Round Robin), Swiss pairing - Avance automático de ganadores - Asignación de canchas y horarios - Registro y confirmación de resultados 3. LIGAS POR EQUIPOS - Creación de equipos con capitán - Calendario round-robin automático - Tabla de clasificación con desempates - Estadísticas por equipo Modelos DB: - Tournament, TournamentParticipant, TournamentMatch - League, LeagueTeam, LeagueTeamMember, LeagueMatch, LeagueStanding Nuevos endpoints: - /tournaments/* - Gestión de torneos - /tournaments/:id/draw/* - Cuadros - /tournaments/:id/matches/* - Partidos de torneo - /leagues/* - Ligas - /league-teams/* - Equipos - /league-schedule/* - Calendario - /league-standings/* - Clasificación - /league-matches/* - Partidos de liga Datos de prueba: - Torneo de Verano 2024 (Eliminatoria) - Liga de Invierno (Round Robin) - Liga de Club 2024
This commit is contained in:
96
backend/prisma/seed-fase3.ts
Normal file
96
backend/prisma/seed-fase3.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
console.log('🌱 Seeding Fase 3 - Torneos y Ligas...\n');
|
||||
|
||||
const admin = await prisma.user.findUnique({ where: { email: 'admin@padel.com' } });
|
||||
|
||||
if (!admin) {
|
||||
console.log('❌ Admin no encontrado. Ejecuta seed.ts primero.');
|
||||
return;
|
||||
}
|
||||
|
||||
const courts = await prisma.court.findMany({ where: { isActive: true }, take: 2 });
|
||||
const courtIds = JSON.stringify(courts.map(c => c.id));
|
||||
|
||||
// Crear torneo de eliminatoria
|
||||
const tournament1 = await prisma.tournament.upsert({
|
||||
where: { id: 'tour-1' },
|
||||
update: {},
|
||||
create: {
|
||||
id: 'tour-1',
|
||||
name: 'Torneo de Verano 2024',
|
||||
description: 'Torneo eliminatorio mixto para todos los niveles',
|
||||
type: 'ELIMINATION',
|
||||
category: 'MIXED',
|
||||
allowedLevels: JSON.stringify(['BEGINNER', 'ELEMENTARY', 'INTERMEDIATE']),
|
||||
maxParticipants: 16,
|
||||
registrationStartDate: new Date(),
|
||||
registrationEndDate: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
|
||||
startDate: new Date(Date.now() + 14 * 24 * 60 * 60 * 1000),
|
||||
endDate: new Date(Date.now() + 21 * 24 * 60 * 60 * 1000),
|
||||
courtIds: courtIds,
|
||||
price: 2000,
|
||||
status: 'OPEN',
|
||||
createdById: admin.id,
|
||||
},
|
||||
});
|
||||
console.log(`✅ Torneo creado: ${tournament1.name}`);
|
||||
|
||||
// Crear torneo round robin
|
||||
const tournament2 = await prisma.tournament.upsert({
|
||||
where: { id: 'tour-2' },
|
||||
update: {},
|
||||
create: {
|
||||
id: 'tour-2',
|
||||
name: 'Liga de Invierno - Individual',
|
||||
description: 'Liga todos contra todos',
|
||||
type: 'ROUND_ROBIN',
|
||||
category: 'MEN',
|
||||
allowedLevels: JSON.stringify(['INTERMEDIATE', 'ADVANCED', 'COMPETITION']),
|
||||
maxParticipants: 8,
|
||||
registrationStartDate: new Date(),
|
||||
registrationEndDate: new Date(Date.now() + 10 * 24 * 60 * 60 * 1000),
|
||||
startDate: new Date(Date.now() + 17 * 24 * 60 * 60 * 1000),
|
||||
endDate: new Date(Date.now() + 60 * 24 * 60 * 60 * 1000),
|
||||
courtIds: courtIds,
|
||||
price: 3000,
|
||||
status: 'DRAFT',
|
||||
createdById: admin.id,
|
||||
},
|
||||
});
|
||||
console.log(`✅ Torneo creado: ${tournament2.name}`);
|
||||
|
||||
// Crear una liga por equipos
|
||||
const league = await prisma.league.upsert({
|
||||
where: { id: 'league-1' },
|
||||
update: {},
|
||||
create: {
|
||||
id: 'league-1',
|
||||
name: 'Liga de Club 2024',
|
||||
description: 'Liga interna del club por equipos',
|
||||
format: 'SINGLE_ROUND_ROBIN',
|
||||
startDate: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
|
||||
endDate: new Date(Date.now() + 90 * 24 * 60 * 60 * 1000),
|
||||
status: 'DRAFT',
|
||||
createdById: admin.id,
|
||||
},
|
||||
});
|
||||
console.log(`✅ Liga creada: ${league.name}`);
|
||||
|
||||
console.log('\n🎾 Fase 3 seed completado!');
|
||||
console.log('\nDatos creados:');
|
||||
console.log(` - 2 Torneos (Eliminatoria, Round Robin)`);
|
||||
console.log(` - 1 Liga por equipos`);
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect();
|
||||
});
|
||||
Reference in New Issue
Block a user