Skip to content
Snippets Groups Projects
Commit 18454eb4 authored by Leon A. Okida Gonçalves's avatar Leon A. Okida Gonçalves
Browse files

Add shift converter

parent f5442479
Branches
Tags
4 merge requests!377prd_version of simcaq,!368update filter in v2 school,!354Development,!353V2 aggregated routes
/*
Copyright (C) 2016 Centro de Computacao Cientifica e Software Livre
Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR
This file is part of simcaq-node.
simcaq-node is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
simcaq-node is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with simcaq-node. If not, see <https://www.gnu.org/licenses/>.
*/
module.exports = function shift(id) {
switch(id) {
case 1:
return 'Parcial';
case 2:
return 'Integral';
default:
return 'Não especificado';
}
}
\ No newline at end of file
......@@ -95,6 +95,7 @@ const enrollmentSituation = require(`${libs}/convert/enrollmentSituation`);
const diffLocation = require(`${libs}/convert/diffLocation`);
const peePorCategoria = require(`${libs}/convert/peePorCategoria`);
const pee = require(`${libs}/convert/booleanVariable`);
const shift = require(`${libs}/convert/shift`);
const ids = {
gender_id: gender,
......@@ -181,7 +182,8 @@ const ids = {
enrollment_situation: enrollmentSituation,
diff_location_id: diffLocation,
pee_por_categoria: peePorCategoria,
pee_id: pee
pee_id: pee,
shift_id: shift
};
function transform(removeId=false) {
......@@ -295,5 +297,6 @@ module.exports = {
enrollmentSituation,
diffLocation,
peePorCategoria,
pee
pee,
shift
};
......@@ -40,6 +40,8 @@ const cache = require('apicache').options({ debug: config.debug, statusCodes: {i
let rqf = new ReqQueryFields();
const id2str = require(`${libs}/middlewares/id2str`);
simcaqFirstReportApp.use(cache('15 day'));
rqf.addField({
......@@ -110,7 +112,7 @@ rqf.addField({
field: 'etapa'
}
}).addValue({
name: 'shift',
name: 'shift_id',
table: 'simcaq_relatorio_1',
tableField: 'turno',
where: {
......@@ -123,7 +125,7 @@ rqf.addField({
simcaqFirstReportApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.from('simcaq_relatorio_1')
.field('simcaq_relatorio_1.etapa', 'education_level_short_id')
.field('simcaq_relatorio_1.turno', 'shift')
.field('simcaq_relatorio_1.turno', 'shift_id')
.field('simcaq_relatorio_1.localizacao_id', 'location')
.field('SUM(simcaq_relatorio_1.num_matriculas)', 'num_enrollments')
.field('SUM(simcaq_relatorio_1.num_escolas)', 'num_schools')
......@@ -133,6 +135,11 @@ simcaqFirstReportApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.group('simcaq_relatorio_1.turno')
.group('simcaq_relatorio_1.localizacao_id');
next();
}, query, response('simcaqFirstReport'));
}, query, (req, res, next) => {
req.result.forEach((result) => {
result.shift = id2str.shift(result.shift_id);
});
next();
}, response('simcaqFirstReport'));
module.exports = simcaqFirstReportApp;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment