diff --git a/src/reportes/participacionAlumno.service.ts b/src/reportes/participacionAlumno.service.ts index 26ed26d..bfb95a0 100644 --- a/src/reportes/participacionAlumno.service.ts +++ b/src/reportes/participacionAlumno.service.ts @@ -49,6 +49,22 @@ export class ParticipacionService { return result; } + async getParticipacionAcademico(): Promise> { + const result = await this.reportesRepository + .createQueryBuilder('usuarios') + .select('COUNT(DISTINCT usuarios.id)', 'Participacion Trabajadores') + .addSelect( + ` + (COUNT(DISTINCT usuarios.id) * 100.0 / (SELECT COUNT(*) FROM usuarios WHERE usuarios.tipo_usuario_id = 4)) AS PorcentajeParticipacion + `, + ) + .innerJoin('usuarios.comentarios', 'clp') + .where('usuarios.tipo_usuario_id = 4') + .getRawOne(); + + return result; + } + async getTotalUsuarios(): Promise { const queryBuilder = await this.tUReportesRepository.createQueryBuilder('tu'); diff --git a/src/reportes/reportes.controller.ts b/src/reportes/reportes.controller.ts index f10b561..32f7059 100644 --- a/src/reportes/reportes.controller.ts +++ b/src/reportes/reportes.controller.ts @@ -1,26 +1,37 @@ -import { Controller, Get } from '@nestjs/common'; +import { Controller, Get, UseGuards } from "@nestjs/common"; import { ParticipacionAlumno } from './ParticipacionAlumno.interface'; import { ParticipacionService } from './participacionAlumno.service'; +import { AuthGuard } from "../auth/auth.guard"; @Controller('reportes') export class ReportesController { constructor(private readonly participacionService: ParticipacionService) {} + @UseGuards(AuthGuard) @Get('participacionAlumnos') async geParticipacionAlumno(): Promise { return this.participacionService.getParticipacionAlumno(); } + @UseGuards(AuthGuard) @Get('participacionTrabajador') async geParticipacionTrabajador(): Promise { return this.participacionService.getParticipacionTrabajador(); } + @UseGuards(AuthGuard) + @Get('participacionAcademico') + async geParticipacionAcademico(): Promise { + return this.participacionService.getParticipacionAcademico(); + } + + @UseGuards(AuthGuard) @Get('totalParticipantes') async getTotalParticipantes(): Promise { return this.participacionService.getTotalUsuarios(); } + @UseGuards(AuthGuard) @Get('totalAlumnosPorCarrera') async getTotalAlumnosPorCarrera(): Promise { return this.participacionService.getTotalAlumnos();