Skip to content
Snippets Groups Projects
Commit efceb26a authored by Fernando Erd's avatar Fernando Erd :ok_hand:
Browse files

Merge remote-tracking branch 'origin/v1.10.0'

parents cc8f46a5 a2e6e4be
No related branches found
No related tags found
1 merge request!198V1.10.0
Pipeline #20244 failed
...@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. ...@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## 1.10.0 - 2019-10-05
## Added
- Added university indicator
## 1.9.8 - 2019-08-02 ## 1.9.8 - 2019-08-02
## Changed ## Changed
- Fix bug duplicate city name in classroom count - Fix bug duplicate city name in classroom count
......
/*
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 academicOrganization(id) {
switch (id) {
case 1:
return 'Universidade';
case 2:
return 'Centro Universitário';
case 3:
return 'Faculdade';
case 4:
return 'Instituto Federal de Educação, Ciência e Tecnologia';
case 5:
return 'Centro Federal de Educação Tecnológica';
default:
return 'Não classificada';
}
};
/*
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 upperAdmDependency(id) {
switch (id) {
case 1:
return 'Pública Federal';
case 2:
return 'Pública Estadual';
case 3:
return 'Pública Municipal';
case 4:
return 'Privada com fins lucrativos';
case 5:
return 'Privada sem fins lucrativos';
case 6:
return 'Privada confessional';
case 7:
return 'Especial';
default:
return 'Não classificada';
}
};
/*
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 libs = `${process.cwd()}/libs`; const libs = `${process.cwd()}/libs`;
const gender = require(`${libs}/convert/gender`); const gender = require(`${libs}/convert/gender`);
const period = require(`${libs}/convert/period`); const period = require(`${libs}/convert/period`);
...@@ -7,6 +27,7 @@ const admDependencyPriv = require(`${libs}/convert/admDependencyPriv`); ...@@ -7,6 +27,7 @@ const admDependencyPriv = require(`${libs}/convert/admDependencyPriv`);
const location = require(`${libs}/convert/location`); const location = require(`${libs}/convert/location`);
const ruralLocation = require(`${libs}/convert/ruralLocation`); const ruralLocation = require(`${libs}/convert/ruralLocation`);
const ethnicGroup = require(`${libs}/convert/ethnicGroup`); const ethnicGroup = require(`${libs}/convert/ethnicGroup`);
const ethnicGroupIES = require(`${libs}/convert/ethnicGroupIES`);
const agreement = require(`${libs}/convert/agreement`); const agreement = require(`${libs}/convert/agreement`);
const booleanVariable = require(`${libs}/convert/booleanVariable`); const booleanVariable = require(`${libs}/convert/booleanVariable`);
const educationLevel = require(`${libs}/convert/educationLevel`); const educationLevel = require(`${libs}/convert/educationLevel`);
...@@ -33,6 +54,28 @@ const specialClass = require(`${libs}/convert/booleanVariable`); ...@@ -33,6 +54,28 @@ const specialClass = require(`${libs}/convert/booleanVariable`);
const integralTime = require(`${libs}/convert/integralTime`); const integralTime = require(`${libs}/convert/integralTime`);
const educationLevelSchoolYear = require(`${libs}/convert/educationLevelSchoolYear`); const educationLevelSchoolYear = require(`${libs}/convert/educationLevelSchoolYear`);
const pfe = require(`${libs}/convert/pfe`); const pfe = require(`${libs}/convert/pfe`);
const upperAdmDependency = require(`${libs}/convert/upperAdmDependency`);
const academicOrganization = require(`${libs}/convert/academicOrganization`);
const ocdeSpecific = require(`${libs}/convert/ocdeSpecific`);
const ocdeGeral = require(`${libs}/convert/ocdeGeral`);
const ocdeDetailed = require(`${libs}/convert/ocdeDetailed`);
const academicLevel = require(`${libs}/convert/academicLevel`);
const upperEducationMod = require(`${libs}/convert/upperEducationMod`);
const studentDeficiency = require(`${libs}/convert/studentDeficiency`);
const schoolType = require(`${libs}/convert/schoolType`);
const upperTurn = require(`${libs}/convert/upperTurn`);
const teacherSituation = require(`${libs}/convert/teacherSituation`);
const workRegime = require(`${libs}/convert/workRegime`);
const substitute = require(`${libs}/convert/booleanVariable`);
const visitor = require(`${libs}/convert/booleanVariable`);
const eadTeacher = require(`${libs}/convert/booleanVariable`);
const graduationPresential = require(`${libs}/convert/booleanVariable`);
const postgraduateEadTeacher = require(`${libs}/convert/booleanVariable`);
const postgraduatePresentialTeacher = require(`${libs}/convert/booleanVariable`);
const teacherSchooling = require(`${libs}/convert/teacherSchooling`);
const ethnicGroupTeacherIES = require(`${libs}/convert/ethnicGroupTeacherIES`);
const genderIES = require(`${libs}/convert/genderIES`);
const deficiency = require(`${libs}/convert/booleanVariable`);
const ids = { const ids = {
gender_id: gender, gender_id: gender,
...@@ -77,6 +120,32 @@ const ids = { ...@@ -77,6 +120,32 @@ const ids = {
special_class_id: specialClass, special_class_id: specialClass,
education_level_school_year_id: educationLevelSchoolYear, education_level_school_year_id: educationLevelSchoolYear,
pfe_id: pfe, pfe_id: pfe,
upper_adm_dependency_id: upperAdmDependency,
academic_organization_id: academicOrganization,
ocde_specific_id: ocdeSpecific,
ocde_geral_id: ocdeGeral,
ocde_detailed_id: ocdeDetailed,
academic_level_id: academicLevel,
upper_education_mod_id: upperEducationMod,
student_deficiency_id: studentDeficiency,
school_type_id: schoolType,
upper_turn_id: upperTurn,
is_free_id: booleanVariable,
night_time_id: booleanVariable,
capital_id: booleanVariable,
ethnic_group_ies_id: ethnicGroupIES,
teacher_situation_id: teacherSituation,
work_regime_id: workRegime,
substitute_id: booleanVariable,
visitor_id: booleanVariable,
ead_teacher_id: eadTeacher,
graduation_presential_id: graduationPresential,
postgraduate_ead_teacher_id: postgraduateEadTeacher,
postgraduate_presential_teacher_id: postgraduatePresentialTeacher,
teacher_schooling_id: teacherSchooling,
ethnic_group_teacher_ies_id: ethnicGroupTeacherIES,
gender_ies_id: genderIES,
deficiency_id: deficiency
}; };
function transform(removeId=false) { function transform(removeId=false) {
...@@ -147,5 +216,28 @@ module.exports = { ...@@ -147,5 +216,28 @@ module.exports = {
useTransport, useTransport,
transportationManager, transportationManager,
specialClass, specialClass,
integralTime integralTime,
upperAdmDependency,
academicOrganization,
ocdeSpecific,
ocdeGeral,
ocdeDetailed,
academicLevel,
upperEducationMod,
studentDeficiency,
schoolType,
ethnicGroupIES,
upperTurn,
teacherSituation,
workRegime,
substitute,
visitor,
eadTeacher,
graduationPresential,
postgraduateEadTeacher,
postgraduatePresentialTeacher,
teacherSchooling,
ethnicGroupTeacherIES,
genderIES,
deficiency
}; };
/*
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 express = require('express');
const api = express(); const api = express();
...@@ -20,8 +40,6 @@ const school = require('./school'); ...@@ -20,8 +40,6 @@ const school = require('./school');
const simulation = require('./simulation'); const simulation = require('./simulation');
const user = require('./user');
const classroom = require('./classroom'); const classroom = require('./classroom');
const teacher = require('./teacher'); const teacher = require('./teacher');
...@@ -44,16 +62,8 @@ const idhmr = require('./idhmr'); ...@@ -44,16 +62,8 @@ const idhmr = require('./idhmr');
const idhml = require('./idhml'); const idhml = require('./idhml');
const oauth2 = require(`${libs}/middlewares/oauth2`);
const verifyToken = require(`${libs}/routes/verifyToken`);
const resetToken = require(`${libs}/routes/resetToken`);
const educationYears = require(`${libs}/routes/educationYears`); const educationYears = require(`${libs}/routes/educationYears`);
const downloads = require(`${libs}/routes/downloads`);
const infrastructure = require(`${libs}/routes/infrastructure`); const infrastructure = require(`${libs}/routes/infrastructure`);
const schoolInfrastructure = require(`${libs}/routes/schoolInfrastructure`); const schoolInfrastructure = require(`${libs}/routes/schoolInfrastructure`);
...@@ -86,12 +96,13 @@ const employees = require(`${libs}/routes/employees`); ...@@ -86,12 +96,13 @@ const employees = require(`${libs}/routes/employees`);
const financial = require(`${libs}/routes/financial`); const financial = require(`${libs}/routes/financial`);
const university = require(`${libs}/routes/university`);
api.get('/', (req, res) => { api.get('/', (req, res) => {
res.json({ msg: 'SimCAQ API is running' }); res.json({ msg: 'SimCAQ API is running' });
}); });
// mount API routes // mount API routes
api.use('/user', user);
api.use('/simulation', simulation); api.use('/simulation', simulation);
api.use('/class', classes); api.use('/class', classes);
api.use('/enrollment', enrollment); api.use('/enrollment', enrollment);
...@@ -110,11 +121,7 @@ api.use('/rate_school', rateSchool); ...@@ -110,11 +121,7 @@ api.use('/rate_school', rateSchool);
api.use('/gloss_enrollment_ratio', glossEnrollmentRatio); api.use('/gloss_enrollment_ratio', glossEnrollmentRatio);
api.use('/liquid_enrollment_ratio', liquidEnrollmentRatio); api.use('/liquid_enrollment_ratio', liquidEnrollmentRatio);
api.use('/idhml', idhml); api.use('/idhml', idhml);
api.use('/auth/token', oauth2.token);
api.use('/verify', verifyToken);
api.use('/reset', resetToken);
api.use('/education_years', educationYears); api.use('/education_years', educationYears);
api.use('/downloads', downloads);
api.use('/infrastructure', infrastructure); api.use('/infrastructure', infrastructure);
api.use('/school_infrastructure', schoolInfrastructure); api.use('/school_infrastructure', schoolInfrastructure);
api.use('/distribution_factor', distributionFactor); api.use('/distribution_factor', distributionFactor);
...@@ -131,6 +138,6 @@ api.use('/portal_mec_inep', portalMecInep); ...@@ -131,6 +138,6 @@ api.use('/portal_mec_inep', portalMecInep);
api.use('/enrollment_projection', enrollmentProjection); api.use('/enrollment_projection', enrollmentProjection);
api.use('/employees', employees); api.use('/employees', employees);
api.use('/financial', financial); api.use('/financial', financial);
api.use('/university', university);
module.exports = api; 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 universityApp = express.Router();
const libs = `${process.cwd()}/libs`;
const log = require(`${libs}/log`)(module);
const squel = require('squel');
const query = require(`${libs}/middlewares/query`).query;
const response = require(`${libs}/middlewares/response`);
const id2str = require(`${libs}/middlewares/id2str`);
const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
const request = require(`request`);
const config = require(`${libs}/config`);
const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
const addMissing = require(`${libs}/middlewares/addMissing`);
let rqf = new ReqQueryFields();
let rqfCount = new ReqQueryFields();
universityApp.use(cache('15 day'));
universityApp.get('/upper_adm_dependency', (req, res, next) => {
req.result = [];
for(let i = 1; i <= 7; ++i) {
req.result.push({
id: i,
name: id2str.upperAdmDependency(i)
});
};
next();
}, response('upper_adm_dependency'));
universityApp.get('/years', (req, res, next) => {
req.sql.from('ies_ens_superior')
.field('DISTINCT ies_ens_superior.ano_censo', 'year')
.where('ies_ens_superior.ano_censo = 2017');
next();
}, query, response('years'));
universityApp.get('/year_range', (req, res, next) => {
req.sql.from('ies_ens_superior')
.field('MIN(ies_ens_superior.ano_censo)', 'start_year')
.field('MAX(ies_ens_superior.ano_censo)', 'end_year');
next();
}, query, response('range'));
universityApp.get('/academic_organization', (req, res, next) => {
req.result = [];
for(let i = 1; i <= 5; ++i) {
req.result.push({
id: i,
name: id2str.academicOrganization(i)
});
};
next();
}, response('academic_organization'));
universityApp.get('/capital', (req, res, next) => {
req.result = [];
for(let i = 0; i <= 1; ++i) {
req.result.push({
id: i,
name: id2str.booleanVariable(i)
});
};
next();
}, response('capital'));
rqf.addField({
name: 'filter',
field: false,
where: true
}).addValue({
name: 'id',
table: 'ies_ens_superior',
tableField: 'cod_ies',
resultField: 'id',
where: {
relation: '=',
type: 'integer',
field: 'cod_ies'
}
}).addValue({
name: 'city',
table: 'municipio',
tableField: 'nome',
resultField: 'city_name',
where: {
relation: '=',
type: 'integer',
field: 'cod_municipio_ies',
table: 'ies_ens_superior'
},
join: {
primary: 'id',
foreign: 'cod_municipio_ies',
foreignTable: 'ies_ens_superior'
}
}).addValue({
name: 'state',
table: 'estado',
tableField: 'nome',
resultField: 'state_name',
where: {
relation: '=',
type: 'integer',
field: 'cod_uf_ies',
table: 'ies_ens_superior'
},
join: {
primary: 'id',
foreign: 'cod_uf_ies',
foreignTable: 'ies_ens_superior'
}
}).addValue({
name: 'year',
table: 'ies_ens_superior',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '=',
type: 'integer',
field: 'ano_censo',
table: 'ies_ens_superior'
}
}).addField({
name: 'search',
field: true,
where: true
}).addValueToField({
name: 'city_name',
table: 'municipio',
tableField: 'nome',
resultField: 'city_name',
dontGroup: true,
where: {
relation: 'LIKE',
type: 'string',
field: 'nome'
},
join: {
primary: 'id',
foreign: 'cod_municipio_ies',
foreignTable: 'ies_ens_superior'
}
}, 'search')
.addValueToField({
name: 'state_name',
table: 'estado',
tableField: 'nome',
resultField: 'state_name',
dontGroup: true,
where: {
relation: 'LIKE',
type: 'string',
field: 'sigla'
},
join: {
primary: 'id',
foreign: 'cod_uf_ies',
foreignTable: 'ies_ens_superior'
}
}, 'search');
rqfCount.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: 'cod_municipio_ies',
table: 'ies_ens_superior'
},
join: {
primary: 'id',
foreign: 'cod_municipio_ies',
foreignTable: 'ies_ens_superior'
}
}).addValue({
name: 'region',
table: 'regiao',
tableField: ['nome', 'id'],
resultField: ['region_name', 'region_id'],
where: {
relation: 'LIKE',
type: 'string',
field: 'id'
},
join: {
primary: 'nome',
foreign: 'nome_regiao_ies',
foreignTable: 'ies_ens_superior'
}
}).addValue({
name: 'min_year',
table: '@',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '>=',
type: 'integer',
table: '@',
field: 'ano_censo'
}
}).addValue({
name: 'max_year',
table: '@',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '<=',
type: 'integer',
table: '@',
field: 'ano_censo'
}
}).addValue({
name: 'state',
table: 'estado',
tableField: ['nome', 'id'],
resultField: ['state_name', 'state_id'],
where: {
relation: '=',
type: 'integer',
field: 'cod_uf_ies',
table: '@'
},
join: {
primary: 'id',
foreign: 'cod_uf_ies',
foreignTable: '@'
}
}).addValue({
name: 'upper_adm_dependency',
table: 'ies_ens_superior',
tableField: 'cod_categoria_administrativa',
resultField: 'upper_adm_dependency_id',
where: {
relation: '=',
type: 'integer',
table: 'ies_ens_superior',
field: 'cod_categoria_administrativa'
}
}).addValue({
name: 'academic_organization',
table: 'ies_ens_superior',
tableField: 'cod_organizacao_academica',
resultField: 'academic_organization_id',
where: {
relation: '=',
type: 'integer',
table: 'ies_ens_superior',
field: 'cod_organizacao_academica'
}
}).addValue({
name: 'capital',
table: 'ies_ens_superior',
tableField: 'capital_ies',
resultField: 'capital_id',
where: {
relation: '=',
type: 'integer',
table: 'ies_ens_superior',
field: 'capital_ies'
}
});
universityApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.from('ies_ens_superior')
.field('ies_ens_superior.cod_ies', 'id')
.field('ies_ens_superior.ano_censo', 'year')
.field('ies_ens_superior.nome_ies', 'name')
.field('ies_ens_superior.cod_uf_ies', 'state_id')
.field('ies_ens_superior.cod_municipio_ies', 'city_id');
next();
}, query, response('university'));
universityApp.get('/count', rqfCount.parse(), (req, res, next) => {
req.sql.field('COUNT(*)', 'total')
.field("'Brasil'", 'name')
.field('ies_ens_superior.ano_censo', 'year')
.from('ies_ens_superior')
.group('ies_ens_superior.ano_censo')
.order('ies_ens_superior.ano_censo')
next();
}, rqfCount.build(), query, addMissing(rqfCount), id2str.transform(), response('university'));
module.exports = universityApp;
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