Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

randomic static returns #55

Merged
merged 6 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/src/controllers/enrollmentController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ export const EnrollmentController = async (req: Request, res: Response) => {
const { municipio, etapa } = req.query;

if (typeof municipio !== 'string' || typeof etapa !== 'string') {
return res.status(400).json({ message: 'Parâmetros inválidos.' });
return res.status(400).json({ message: 'Município ou Etapa inválidos.' });
}
if (!municipio || !etapa) {
return res.status(400).json({ error: 'Municipio e etapa são obrigatórios' });
return res.status(400).json({ message: 'Municipio e Etapa são obrigatórios.' });
}

const service = new MatriculasService(new MatriculasRepositoryPSQL());
Expand Down
18 changes: 15 additions & 3 deletions api/src/controllers/indicatorController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@ export const IndicatorController = async (req: Request, res: Response) => {
series: [
{
name: 'Brancos',
data: [12, 34, 14, 29, 45],
data: [
Math.floor(Math.random() * 10001),
Math.floor(Math.random() * 10001),
Math.floor(Math.random() * 10001),
Math.floor(Math.random() * 10001),
Math.floor(Math.random() * 10001),
],
},
{
name: 'Pretos',
data: [20, 22, 23, 19, 30],
name: 'Pretos/Pardos',
data: [
Math.floor(Math.random() * 10001),
Math.floor(Math.random() * 10001),
Math.floor(Math.random() * 10001),
Math.floor(Math.random() * 10001),
Math.floor(Math.random() * 10001),
],
},
],
};
Expand Down
42 changes: 32 additions & 10 deletions api/src/controllers/rankingController.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,40 @@
import { Request, Response } from 'express';

export const RankingController = async (req: Request, res: Response) => {
const { ano, etapa, ordem } = req.query;
console.log(`Ranking Ano: ${ano} - Etapa: ${etapa} - Ordem: ${ordem}`);
const { ano, etapa } = req.query;
console.log(`Ranking Ano: ${ano} - Etapa: ${etapa}`);

const response = [
{ name: 'Belo Horizonte', value: 10 },
{ name: 'Patos de Minas', value: 9 },
{ name: 'Uberlândia', value: 8 },
{ name: 'Santana de Cataguases', value: 7 },
{ name: 'Tiros', value: 6.4 },
{ name: 'Uberaba', value: 6 },
{ name: 'Vargem Bonita', value: 5 },
{ name: 'Governador Valadares', value: 4.2 },
{ name: 'Belo Horizonte', value: Math.floor(Math.random() * 101) },
{ name: 'Patos de Minas', value: Math.floor(Math.random() * 101) },
{ name: 'Uberlândia', value: Math.floor(Math.random() * 101) },
{ name: 'Santana de Cataguases', value: Math.floor(Math.random() * 101) },
{ name: 'Tiros', value: Math.floor(Math.random() * 101) },
{ name: 'Uberaba', value: Math.floor(Math.random() * 101) },
{ name: 'Vargem Bonita', value: Math.floor(Math.random() * 101) },
{ name: 'Governador Valadares', value: Math.floor(Math.random() * 101) },
{ name: 'São João del Rei', value: Math.floor(Math.random() * 101) },
{ name: 'Borda da Mata', value: Math.floor(Math.random() * 101) },
{ name: 'Brumadinho', value: Math.floor(Math.random() * 101) },
{ name: 'Extrema', value: Math.floor(Math.random() * 101) },
{ name: 'Barra Longa', value: Math.floor(Math.random() * 101) },
{ name: 'Barroso', value: Math.floor(Math.random() * 101) },
{ name: 'Cambuí', value: Math.floor(Math.random() * 101) },
{ name: 'Cambuquira', value: Math.floor(Math.random() * 101) },
{ name: 'Campanha', value: Math.floor(Math.random() * 101) },
{ name: 'Caraí', value: Math.floor(Math.random() * 101) },
{ name: 'Engenheiro Caldas', value: Math.floor(Math.random() * 101) },
{ name: 'Entre Folhas', value: Math.floor(Math.random() * 101) },
{ name: 'Felixlândia', value: Math.floor(Math.random() * 101) },
{ name: 'Fernandes Tourinho', value: Math.floor(Math.random() * 101) },
{ name: 'Guarani', value: Math.floor(Math.random() * 101) },
{ name: 'Igarapé', value: Math.floor(Math.random() * 101) },
{ name: 'Ipiaçu', value: Math.floor(Math.random() * 101) },
{ name: 'Jacutinga', value: Math.floor(Math.random() * 101) },
{ name: 'Luisburgo', value: Math.floor(Math.random() * 101) },
{ name: 'Medina', value: Math.floor(Math.random() * 101) },
{ name: 'Lassance', value: Math.floor(Math.random() * 101) },
{ name: 'Passabém', value: Math.floor(Math.random() * 101) },
];

res.json(response);
Expand Down
6 changes: 0 additions & 6 deletions api/src/routes/rankingRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ const router = Router();
* type: string
* required: true
* description: Etapa de ensino
* - in: query
* name: ordem
* schema:
* type: string
* required: true
* description: Ordem do ranking
* responses:
* 200:
* description: Ranking de municípios
Expand Down
2 changes: 1 addition & 1 deletion api/src/services/matriculasServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class MatriculasService {

data.forEach((entry) => {
if (entry.etapa !== input.etapa || entry.municipio.toString() !== input.municipio) {
throw new Error('entry.etapa');
throw new Error('Erro ao processar solicitação.');
}

if (
Expand Down
Loading