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

Add number of teachers route

parent 1cbe5c37
No related branches found
No related tags found
4 merge requests!377prd_version of simcaq,!368update filter in v2 school,!364fix issue with the simcaq_second_report_route where the...,!363Add simcaq_new_classes, simcaq_result and simcaq_number_of_teachers routes; fix issue with filter in simcaq_second_report
/*
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 level(id) {
switch(id) {
case 1:
return 'Brasil';
case 2:
return 'Estadual';
case 3:
return 'Municipal';
default:
return 'Não especificado';
}
}
\ No newline at end of file
/*
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 type(id) {
switch(id) {
case 1:
return 'Plano';
case 2:
return 'Rede';
default:
return 'Não especificado';
}
}
\ No newline at end of file
......@@ -98,6 +98,8 @@ const pee = require(`${libs}/convert/booleanVariable`);
const shift = require(`${libs}/convert/shift`);
const admDependencyPub = require(`${libs}/convert/admDependencyPub`);
const supplyDimension = require(`${libs}/convert/supplyDimension`);
const type = require(`${libs}/convert/type`);
const level = require(`${libs}/convert/level`);
const ids = {
gender_id: gender,
......@@ -187,7 +189,9 @@ const ids = {
pee_por_categoria: peePorCategoria,
pee_id: pee,
shift_id: shift,
supply_dimension_id: supplyDimension
supply_dimension_id: supplyDimension,
type_id: type,
level_id: level
};
function transform(removeId=false) {
......
......@@ -152,6 +152,8 @@ const simcaqNewClasses = require(`${libs}/routes_v2/simcaqNewClasses`);
const simcaqResult = require(`${libs}/routes_v2/simcaqResult`);
const simcaqNumberOfTeachers = require(`${libs}/routes_v2/simcaqNumberOfTeachers`);
api.get('/', (req, res) => {
res.json({ msg: 'SimCAQ API v2 is running' });
});
......@@ -219,5 +221,6 @@ api.use('/simcaq_workload', simcaqWorkload);
api.use('/simcaq_number_of_employees', simcaqNumberOfEmployees);
api.use('/simcaq_new_classes', simcaqNewClasses);
api.use('/simcaq_result', simcaqResult);
api.use('/simcaq_number_of_teachers', simcaqNumberOfTeachers);
module.exports = api;
/*
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/>.
*/
const express = require('express');
const simcaqNumberOfTeachersApp = express.Router();
const libs = `${process.cwd()}/libs`;
const squel = require('squel');
const query = require(`${libs}/middlewares/query`).query;
const response = require(`${libs}/middlewares/response`);
const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
const reqBody = require(`${libs}/middlewares/reqBody`);
const config = require(`${libs}/config`);
const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
let rqf = new ReqQueryFields();
const id2str = require(`${libs}/middlewares/id2str`);
simcaqNumberOfTeachersApp.use(cache('15 day'));
rqf.addField({
name: 'filter',
field: false,
where: true
}).addField({
name: 'dims',
field: true,
where: false
}).addValue({
name: 'year',
table: 'simcaq_num_professores',
tableField: 'ano_censo',
where: {
relation: '=',
type: 'integer',
field: 'ano_censo'
}
}).addValue({
name: 'local_id',
table: 'simcaq_num_professores',
tableField: 'local_id',
where: {
relation: '=',
type: 'integer',
field: 'local_id'
}
}).addValue({
name: 'level_id',
table: 'simcaq_num_professores',
tableField: 'nivel',
where: {
relation: '=',
type: 'integer',
field: 'nivel'
}
}).addValue({
name: 'type_id',
table: 'simcaq_num_professores',
tableField: 'tipo',
where: {
relation: '=',
type: 'integer',
field: 'tipo'
}
});
simcaqNumberOfTeachersApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.from('simcaq_num_professores')
.field('total', 'number_of_teachers')
.field('simcaq_num_professores.ano_censo', 'year')
.field('simcaq_num_professores.nivel', 'level_id')
.field('simcaq_num_professores.tipo', 'type_id')
.field('simcaq_num_professores.local_id', 'local_id');
next();
}, query, id2str.transform(), response('simcaqNumberOfTeachers'));
module.exports = simcaqNumberOfTeachersApp;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment