7 Commits

5 changed files with 38 additions and 6 deletions
+5 -5
View File
@@ -1,10 +1,10 @@
PORT=5089
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=password
DB_NAME=cedetec_proyectos
DB_PORT=3306
DB_HOST=132.248.180.82
DB_USER=user_cedetec
DB_PASSWORD=c3t3d3c
DB_NAME=Betelgeuse_Cedetec_Prueba
DB_PORT=
DB_HOST_DSC = 132.248.180.82
DB_USER_DSC = sites_user
+11
View File
@@ -0,0 +1,11 @@
PORT=
DB_HOST=
DB_USER=
DB_PASSWORD=
DB_NAME=
DB_HOST_DSC=
DB_USER_DSC=
DB_PASS_DSC=
DB_NAME_DSC=
+1 -1
View File
@@ -12,5 +12,5 @@ export class TipoMiembro {
@OneToMany(
() => Miembro, (miembro) => miembro.tipoMiembro
)
miembro: Miembro
miembro: Miembro[]
}
+8
View File
@@ -1,4 +1,7 @@
import { Body, Controller, Delete, Get, Param, ParseIntPipe, Patch, Post } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { EventoParticipante } from 'src/evento-participante/evento-participante/eventoParticipante.entity';
import { Repository } from 'typeorm';
import { actualizarEventoDto } from './dto/actualizarEvento.dto';
import { crearEventoDto } from './dto/crearEvento.dto';
import { Evento } from './evento.entity';
@@ -33,4 +36,9 @@ export class EventosController {
deleteEvento(@Param('id', ParseIntPipe)id: number){
return this.eventoService.deleteEventoParticipante(id)
}
@Get(':id/participantes')
async getCupos(@Param('id', ParseIntPipe)id: number){
return this.eventoService.getCupos(id)
}
}
+13
View File
@@ -60,4 +60,17 @@ export class EventosService {
await queryRunner.release();
}
}
async getCupos(id: number){
const evento = this.getEventosPorId(id)
if(!evento) throw new Error(`El evento con id:${id} no existe`)
const registrados = await this.eventoParticipanteRepository
.createQueryBuilder('ep')
.select('COUNT(ep.id_evento)', 'count')
.where('ep.id_evento = :eventoId', { eventoId: (await evento).id_evento })
.getRawOne();
const cupoOriginal = (await evento).cupo;
const cupoDisponible = cupoOriginal - registrados.count;
return { registrados: registrados.count, cupoDisponible, cupoOriginal};
}
}