Skip to content
Snippets Groups Projects
Commit 1d0aa98a authored by Pietro Cavassin's avatar Pietro Cavassin
Browse files

Merge branch 'development' into 'homologa'

Development

See merge request !362
parents 5818f294 f835ac97
Branches
Tags
3 merge requests!407Master,!377prd_version of simcaq,!362Development
......@@ -142,6 +142,12 @@ const simcaqSecondReport = require(`${libs}/routes_v2/simcaqSecondReport`);
const simcaqDivisionOfResponsibility = require(`${libs}/routes_v2/simcaqDivisionOfResponsibility`);
const simcaqClassroomSize = require(`${libs}/routes_v2/simcaqClassroomSize`);
const simcaqWorkload = require(`${libs}/routes_v2/simcaqWorkload`);
const simcaqNumberOfEmployees = require(`${libs}/routes_v2/simcaqNumberOfEmployees`);
api.get('/', (req, res) => {
res.json({ msg: 'SimCAQ API v2 is running' });
});
......@@ -204,5 +210,8 @@ api.use('/simcaq_first_report', simcaqFirstReport);
api.use('/simcaq_enrollment_diagnosis', simcaqEnrollmentDiagnosis);
api.use('/simcaq_second_report', simcaqSecondReport);
api.use('/simcaq_division_of_responsibility', simcaqDivisionOfResponsibility);
api.use('/simcaq_classroom_size', simcaqClassroomSize);
api.use('/simcaq_workload', simcaqWorkload);
api.use('/simcaq_number_of_employees', simcaqNumberOfEmployees);
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 simcaqClassroomSizeApp = 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`);
simcaqClassroomSizeApp.use(cache('15 day'));
rqf.addField({
name: 'filter',
field: false,
where: true
}).addField({
name: 'dims',
field: true,
where: false
}).addValue({
name: 'city',
table: 'municipio',
tableField: ['nome', 'id'],
resultField: ['city_name', 'city_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'municipio_id',
foreignTable: 'simcaq_tamanho_das_turmas'
}
}, 'dims').addValue({
name: 'state',
table: 'estado',
tableField: ['nome', 'id'],
resultField: ['state_name', 'state_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'estado_id',
foreignTable: 'simcaq_tamanho_das_turmas'
}
}, 'dims').addValue({
name: 'school',
table: 'escola_agregada',
tableField: 'id',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'escola_id',
foreignTable: 'simcaq_tamanho_das_turmas'
}
}, 'dims').addValue({
name: 'education_level_short_id',
table: 'simcaq_tamanho_das_turmas',
tableField: 'etapa',
where: {
relation: '=',
type: 'integer',
field: 'etapa'
}
}).addValue({
name: 'location',
table: 'simcaq_tamanho_das_turmas',
tableField: 'localizacao_id',
where: {
relation: '=',
type: 'integer',
field: 'localizacao_id'
}
}).addValue({
name: 'adm_dependency_public_id',
table: 'simcaq_tamanho_das_turmas',
tableField: 'rede',
where: {
relation: '=',
type: 'integer',
field: 'rede'
}
}).addValue({
name: 'year',
table: 'simcaq_tamanho_das_turmas',
tableField: 'ano_censo',
where: {
relation: '=',
type: 'integer',
field: 'ano_censo'
}
});
simcaqClassroomSizeApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.from('simcaq_tamanho_das_turmas')
.field('AVG(simcaq_tamanho_das_turmas.num_matricula)', 'average_classroom_size')
.field('simcaq_tamanho_das_turmas.etapa', 'education_level_short_id')
.field('simcaq_tamanho_das_turmas.ano_censo', 'year')
.group('simcaq_tamanho_das_turmas.ano_censo')
.group('simcaq_tamanho_das_turmas.etapa');
next();
}, query, id2str.transform(), response('classroomSize'));
module.exports = simcaqClassroomSizeApp;
......@@ -127,9 +127,11 @@ rqf.addField({
simcaqDivisionOfResponsibilityApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.from('simcaq_divisao_de_responsabilidade')
.field('simcaq_divisao_de_responsabilidade.ano_censo', 'year')
.field('SUM(simcaq_divisao_de_responsabilidade.total_matriculas)', 'enrollments')
.field('simcaq_divisao_de_responsabilidade.etapa', 'education_level_short_id')
.field('simcaq_divisao_de_responsabilidade.rede', 'adm_dependency_public_id')
.group('simcaq_divisao_de_responsabilidade.ano_censo')
.group('simcaq_divisao_de_responsabilidade.etapa')
.group('simcaq_divisao_de_responsabilidade.rede');
next();
......
/*
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 simcaqNumberOfEmployeesApp = 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`);
simcaqNumberOfEmployeesApp.use(cache('15 day'));
rqf.addField({
name: 'filter',
field: false,
where: true
}).addField({
name: 'dims',
field: true,
where: false
}).addValue({
name: 'year',
table: 'simcaq_numero_de_funcionarios',
tableField: 'ano_censo',
where: {
relation: '=',
type: 'integer',
field: 'ano_censo'
}
}).addValue({
name: 'city',
table: 'municipio',
tableField: ['nome', 'id'],
resultField: ['city_name', 'city_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'municipio_id',
foreignTable: 'simcaq_numero_de_funcionarios'
}
}, 'dims').addValue({
name: 'state',
table: 'estado',
tableField: ['nome', 'id'],
resultField: ['state_name', 'state_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'estado_id',
foreignTable: 'simcaq_numero_de_funcionarios'
}
}, 'dims').addValue({
name: 'school',
table: 'escola_agregada',
tableField: 'id',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'escola_id',
foreignTable: 'simcaq_numero_de_funcionarios'
}
}, 'dims').addValue({
name: 'adm_dependency_public_id',
table: 'simcaq_numero_de_funcionarios',
tableField: 'rede',
where: {
relation: '=',
type: 'integer',
field: 'rede'
}
});
simcaqNumberOfEmployeesApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.from('simcaq_numero_de_funcionarios')
.field('SUM(num_funcionarios)', 'average_number_of_employees')
.field('simcaq_numero_de_funcionarios.rede', 'adm_dependency_public_id')
.field('simcaq_numero_de_funcionarios.ano_censo', 'year')
.group('simcaq_numero_de_funcionarios.rede')
.group('simcaq_numero_de_funcionarios.ano_censo');
next();
}, query, id2str.transform(), response('simcaqNumberOfEmployees'));
module.exports = simcaqNumberOfEmployeesApp;
/*
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 simcaqWorkloadApp = 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`);
simcaqWorkloadApp.use(cache('15 day'));
rqf.addField({
name: 'filter',
field: false,
where: true
}).addField({
name: 'dims',
field: true,
where: false
}).addValue({
name: 'year',
table: 'simcaq_carga_horaria_de_ensino',
tableField: 'ano_censo',
where: {
relation: '=',
type: 'integer',
field: 'ano_censo'
}
}).addValue({
name: 'city',
table: 'municipio',
tableField: ['nome', 'id'],
resultField: ['city_name', 'city_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'municipio_id',
foreignTable: 'simcaq_carga_horaria_de_ensino'
}
}, 'dims').addValue({
name: 'state',
table: 'estado',
tableField: ['nome', 'id'],
resultField: ['state_name', 'state_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'estado_id',
foreignTable: 'simcaq_carga_horaria_de_ensino'
}
}, 'dims').addValue({
name: 'school',
table: 'escola_agregada',
tableField: 'id',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'escola_id',
foreignTable: 'simcaq_carga_horaria_de_ensino'
}
}, 'dims').addValue({
name: 'adm_dependency_public_id',
table: 'simcaq_carga_horaria_de_ensino',
tableField: 'rede',
where: {
relation: '=',
type: 'integer',
field: 'rede'
}
}).addValue({
name: 'education_level_short_id',
table: 'simcaq_carga_horaria_de_ensino',
tableField: 'etapa',
where: {
relation: '=',
type: 'integer',
field: 'etapa'
}
}).addValue({
name: 'shift_id',
table: 'simcaq_carga_horaria_de_ensino',
tableField: 'turno',
where: {
relation: '=',
type: 'integer',
field: 'turno'
}
});
simcaqWorkloadApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.from('simcaq_carga_horaria_de_ensino')
.field('AVG(duracao_turma_horas)', 'average_workload')
.field('simcaq_carga_horaria_de_ensino.etapa', 'education_level_short_id')
.field('simcaq_carga_horaria_de_ensino.turno', 'shift_id')
.field('simcaq_carga_horaria_de_ensino.rede', 'adm_dependency_public_id')
.field('simcaq_carga_horaria_de_ensino.ano_censo', 'year')
.group('simcaq_carga_horaria_de_ensino.etapa')
.group('simcaq_carga_horaria_de_ensino.turno')
.group('simcaq_carga_horaria_de_ensino.rede')
.group('simcaq_carga_horaria_de_ensino.ano_censo');
next();
}, query, id2str.transform(), response('simcaqWorkload'));
module.exports = simcaqWorkloadApp;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment