Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 878bccde38 | |||
| 7556fec383 | |||
| ba9d1b02f6 | |||
| 15fd67c7d9 | |||
| ca3e4c42bd | |||
| 97e1735481 | |||
| a2f83a7a00 |
@@ -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
|
||||
|
||||
@@ -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=
|
||||
@@ -12,5 +12,5 @@ export class TipoMiembro {
|
||||
@OneToMany(
|
||||
() => Miembro, (miembro) => miembro.tipoMiembro
|
||||
)
|
||||
miembro: Miembro
|
||||
miembro: Miembro[]
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user