From e8ce12e01221fa033bd288b9f549ec9c2c56a3bc Mon Sep 17 00:00:00 2001 From: Joao Kieras <jpko19@inf.ufpr.br> Date: Thu, 11 Aug 2022 11:45:58 -0300 Subject: [PATCH] Update dims pee_por_categoria --- src/libs/routes/enrollment.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index 26e1cb30..52788490 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -19,6 +19,7 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>. */ const express = require('express'); +const { result } = require('lodash'); const enrollmentApp = express.Router(); @@ -811,7 +812,29 @@ enrollmentApp.get('/', rqf.parse(), (req, res, next) => { .where('((matricula.tipo<=3 OR matricula.tipo IS NULL) AND (matricula.tipo_atendimento_turma IS NULL OR matricula.tipo_atendimento_turma <= 2))'); } next(); -}, rqf.build(), query, id2str.transform(false), response('enrollment')); +}, rqf.build(), query, id2str.transform(false), (req, res, next) => { + if('pee_por_categoria' in req.dims){ + let result_total = []; + for (var j = 0;j < result.result.length;j++){ + let result_parcial = result.result[j]; + for (var i in result_parcial){ + if(i !== 'year'){ + let obj = { + category_name: '', + year: 0, + total: 0 + }; + obj.category_name = i; + obj.total = result_parcial[i]; + obj.year = result_parcial.year; + result_total.push(obj); + } + } + } + req.result = result_total; + } + next(); +}, response('enrollment')); enrollmentApp.get('/diagnosis', rqf.parse(), (req, res, next) => { req.dims = {}; -- GitLab