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

Merge branch 'v.1.10.4'

parents c675cf43 7853d030
No related branches found
No related tags found
1 merge request!204v1.10.4
Pipeline #20336 failed
...@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. ...@@ -4,6 +4,13 @@ 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.4 - 2019-05-23
## Changed
- Fix order in enrollment indicator
## Added
- Added university enrollment indicator
- Added course count indicator
## 1.10.3 - 2019-05-22 ## 1.10.3 - 2019-05-22
## Changed ## Changed
- Fix schoolInfrastructure.js - Fix schoolInfrastructure.js
......
/*
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 ageStudentCode(id) {
switch (id) {
case 1:
return 'Menor que 18 anos';
case 2:
return 'Entre 18 anos e 24 anos';
case 3:
return 'Entre 25 anos e 29 anos';
case 4:
return 'Entre 30 anos e 34 anos';
case 5:
return 'Entre 35 anos e 39 anos';
case 6:
return 'Maior que 39 anos';
default:
return 'Não classificado';
}
};
...@@ -27,7 +27,7 @@ module.exports = function ocdeGeral(id) { ...@@ -27,7 +27,7 @@ module.exports = function ocdeGeral(id) {
case 2: case 2:
return 'Humanidades e artes'; return 'Humanidades e artes';
case 3: case 3:
return 'Ciências sociais, negócios e direitor'; return 'Ciências sociais, negócios e direito';
case 4: case 4:
return 'Ciências, matemática e computação'; return 'Ciências, matemática e computação';
case 5: case 5:
......
...@@ -37,9 +37,11 @@ module.exports = function ocdeSpecific(id) { ...@@ -37,9 +37,11 @@ module.exports = function ocdeSpecific(id) {
case 38: case 38:
return 'Direito'; return 'Direito';
case 42: case 42:
return 'Ciências'; return 'Ciências da vida';
case 44: case 44:
return 'Ciências físicas'; return 'Ciências físicas';
case 46:
return 'Matemática e estatística';
case 48: case 48:
return 'Computação'; return 'Computação';
case 52: case 52:
......
...@@ -42,6 +42,7 @@ const contractType = require(`${libs}/convert/contractType`); ...@@ -42,6 +42,7 @@ const contractType = require(`${libs}/convert/contractType`);
const ethnicGroupPnad = require(`${libs}/convert/ethnicGroupPnad`); const ethnicGroupPnad = require(`${libs}/convert/ethnicGroupPnad`);
const ageRange = require(`${libs}/convert/ageRange`); const ageRange = require(`${libs}/convert/ageRange`);
const ageRangeAll = require(`${libs}/convert/ageRangeAll`); const ageRangeAll = require(`${libs}/convert/ageRangeAll`);
const ageStudentCode = require(`${libs}/convert/ageStudentCode`);
const fullAgeRange = require(`${libs}/convert/fullAgeRange`); const fullAgeRange = require(`${libs}/convert/fullAgeRange`);
const genderPnad = require(`${libs}/convert/genderPnad`); const genderPnad = require(`${libs}/convert/genderPnad`);
const fifthHouseholdIncome = require(`${libs}/convert/fifthHouseholdIncome`); const fifthHouseholdIncome = require(`${libs}/convert/fifthHouseholdIncome`);
...@@ -75,7 +76,7 @@ const postgraduatePresentialTeacher = require(`${libs}/convert/booleanVariable`) ...@@ -75,7 +76,7 @@ const postgraduatePresentialTeacher = require(`${libs}/convert/booleanVariable`)
const teacherSchooling = require(`${libs}/convert/teacherSchooling`); const teacherSchooling = require(`${libs}/convert/teacherSchooling`);
const ethnicGroupTeacherIES = require(`${libs}/convert/ethnicGroupTeacherIES`); const ethnicGroupTeacherIES = require(`${libs}/convert/ethnicGroupTeacherIES`);
const genderIES = require(`${libs}/convert/genderIES`); const genderIES = require(`${libs}/convert/genderIES`);
const deficiency = require(`${libs}/convert/booleanVariable`); const deficiency = require(`${libs}/convert/studentDeficiency`);
const ids = { const ids = {
gender_id: gender, gender_id: gender,
...@@ -145,7 +146,8 @@ const ids = { ...@@ -145,7 +146,8 @@ const ids = {
teacher_schooling_id: teacherSchooling, teacher_schooling_id: teacherSchooling,
ethnic_group_teacher_ies_id: ethnicGroupTeacherIES, ethnic_group_teacher_ies_id: ethnicGroupTeacherIES,
gender_ies_id: genderIES, gender_ies_id: genderIES,
deficiency_id: deficiency deficiency_id: deficiency,
age_student_code_id: ageStudentCode
}; };
function transform(removeId=false) { function transform(removeId=false) {
...@@ -209,6 +211,7 @@ module.exports = { ...@@ -209,6 +211,7 @@ module.exports = {
ethnicGroupPnad, ethnicGroupPnad,
ageRange, ageRange,
ageRangeAll, ageRangeAll,
ageStudentCode,
fullAgeRange, fullAgeRange,
genderPnad, genderPnad,
fifthHouseholdIncome, fifthHouseholdIncome,
......
...@@ -40,8 +40,6 @@ const school = require('./school'); ...@@ -40,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');
...@@ -64,16 +62,8 @@ const idhmr = require('./idhmr'); ...@@ -64,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`);
...@@ -106,6 +96,10 @@ const employees = require(`${libs}/routes/employees`); ...@@ -106,6 +96,10 @@ const employees = require(`${libs}/routes/employees`);
const financial = require(`${libs}/routes/financial`); const financial = require(`${libs}/routes/financial`);
const universityEnrollment = require(`${libs}/routes/universityEnrollment`);
const courseCount = require(`${libs}/routes/courseCount`);
const university = require(`${libs}/routes/university`); const university = require(`${libs}/routes/university`);
api.get('/', (req, res) => { api.get('/', (req, res) => {
...@@ -113,7 +107,6 @@ api.get('/', (req, res) => { ...@@ -113,7 +107,6 @@ api.get('/', (req, res) => {
}); });
// 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);
...@@ -132,11 +125,7 @@ api.use('/rate_school', rateSchool); ...@@ -132,11 +125,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);
...@@ -153,6 +142,8 @@ api.use('/portal_mec_inep', portalMecInep); ...@@ -153,6 +142,8 @@ 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_enrollment', universityEnrollment);
api.use('/university', university); api.use('/university', university);
api.use('/course_count', courseCount);
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 courseCountApp = 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 ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
const id2str = require(`${libs}/middlewares/id2str`);
const config = require(`${libs}/config`);
const addMissing = require(`${libs}/middlewares/addMissing`);
const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
let rqf = new ReqQueryFields();
courseCountApp.use(cache('15 day'));
courseCountApp.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'));
courseCountApp.get('/years', (req, res, next) => {
req.sql.from('curso_ens_superior')
.field('DISTINCT curso_ens_superior.ano_censo', 'year')
.where('curso_ens_superior.ano_censo = 2017');
next();
}, query, response('years'));
courseCountApp.get('/year_range', (req, res, next) => {
req.sql.from('curso_ens_superior')
.field('MIN(curso_ens_superior.ano_censo)', 'start_year')
.field('MAX(curso_ens_superior.ano_censo)', 'end_year');
next();
}, query, response('range'));
courseCountApp.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'));
courseCountApp.get('/capital', (req, res, next) => {
req.result = [
{id: null, name: 'Não Classificado'},
{id: 0, name: 'Não'},
{id: 1, name: 'Sim'}
];
next();
}, response('capital'));
courseCountApp.get('/ocde_geral', (req, res, next) => {
req.result = [];
for(let i = 1; i <= 8; ++i) {
req.result.push({
id: i,
name: id2str.ocdeGeral(i)
});
};
next();
}, response('ocde_geral'));
courseCountApp.get('/ocde_specific', (req, res, next) => {
req.result = [];
const defaultCase = null;
for(let i = 1; i <= 86; ++i) {
let obj = {
id: i,
name: id2str.ocdeSpecific(i)
};
if (obj.name !== id2str.ocdeSpecific(defaultCase)){
req.result.push(obj);
}
};
req.result.push({
id: defaultCase,
name: id2str.ocdeSpecific(defaultCase)
});
next();
}, response('ocde_specific'));
courseCountApp.get('/ocde_detailed', (req, res, next) => {
req.result = [];
const defaultCase = null;
for(let i = 142; i <= 863; ++i) {
let obj = {
id: i,
name: id2str.ocdeDetailed(i)
};
if (obj.name !== id2str.ocdeDetailed(defaultCase)){
req.result.push(obj);
}
};
req.result.push({
id: defaultCase,
name: id2str.ocdeDetailed(defaultCase)
});
next();
}, response('ocde_detailed'));
courseCountApp.get('/academic_level', (req, res, next) => {
req.result = [];
for(let i = 1; i <= 4; ++i) {
req.result.push({
id: i,
name: id2str.academicLevel(i)
});
};
next();
}, response('academic_level'));
courseCountApp.get('/upper_education_mod', (req, res, next) => {
req.result = [];
for(let i = 1; i <= 3; ++i) {
req.result.push({
id: i,
name: id2str.upperEducationMod(i)
});
};
next();
}, response('upper_education_mod'));
courseCountApp.get('/is_free', (req, res, next) => {
req.result = [
{id: null, name: 'Não Classificado'},
{id: 0, name: 'Não'},
{id: 1, name: 'Sim'}
];
next();
}, response('is_free'));
courseCountApp.get('/night_time', (req, res, next) => {
req.result = [
{id: null, name: 'Não Classificado'},
{id: 0, name: 'Não'},
{id: 1, name: 'Sim'}
];
next();
}, response('night_time'));
courseCountApp.get('/university', (req, res, next) => {
req.sql.from('curso_ens_superior')
.field('DISTINCT curso_ens_superior.nome_ies', 'nome')
.field('curso_ens_superior.cod_ies', 'cod')
next();
}, query, response('university'));
rqf.addField({
name: 'filter',
field: false,
where: true
}).addField({
name: 'dims',
field: true,
where: false
}).addValue({
name: 'region',
table: 'regiao',
tableField: ['nome', 'id'],
resultField: ['region_name', 'region_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'nome',
foreign: 'nome_regiao_curso',
foreignTable: 'curso_ens_superior'
}
}).addValue({
name: 'state',
table: 'estado',
tableField: ['nome', 'id'],
resultField: ['state_name', 'state_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'cod_uf_curso',
foreignTable: 'curso_ens_superior'
}
}).addValue({
name: 'city',
table: 'curso_ens_superior',
tableField: ['municipio_curso', 'cod_municipio_curso'],
resultField: ['city_name', 'city_id'],
where: {
relation: '=',
type: 'integer',
field: 'cod_municipio_curso'
}
}).addValue({
name: 'university',
table: 'curso_ens_superior',
tableField: ['cod_ies', 'nome_ies'],
resultField: ['university_id', 'university_name'],
where: {
relation: '=',
type: 'integer',
field: 'cod_ies'
}
}).addValue({
name:'upper_adm_dependency',
table: 'curso_ens_superior',
tableField: 'cod_categoria_administrativa',
resultField: 'upper_adm_dependency_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_categoria_administrativa'
}
}).addValue({
name:'academic_organization',
table: 'curso_ens_superior',
tableField: 'cod_organizacao_academica',
resultField: 'academic_organization_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_organizacao_academica'
}
}).addValue({
name:'capital',
table: 'curso_ens_superior',
tableField: 'capital_curso',
resultField: 'capital_id',
where: {
relation: '=',
type: 'integer',
field: 'capital_curso'
}
}).addValue({
name:'course',
table: 'curso_ens_superior',
tableField: 'nome_curso',
resultField: 'course_name',
where: {
relation: 'LIKE',
type: 'string',
field: 'nome_curso'
}
}).addValue({
name:'ocde_specific',
table: 'curso_ens_superior',
tableField: ['cod_ocde_area_especifica', 'nome_ocde_area_especifica'],
resultField: ['ocde_specific_id', 'ocde_specific_name'],
where: {
relation: '=',
type: 'integer',
field: 'cod_ocde_area_especifica'
}
}).addValue({
name:'ocde_geral',
table: 'curso_ens_superior',
tableField: ['cod_ocde_area_geral', 'nome_ocde_area_geral'],
resultField: ['ocde_geral_id', 'ocde_geral_name'],
where: {
relation: '=',
type: 'integer',
field: 'cod_ocde_area_geral'
}
}).addValue({
name:'ocde_detailed',
table: 'curso_ens_superior',
tableField: ['cod_ocde_area_detalhada', 'nome_ocde_area_detalhada'],
resultField: ['ocde_detailed_id', 'ocde_datailed_name'],
where: {
relation: '=',
type: 'integer',
field: 'cod_ocde_area_detalhada'
}
}).addValue({
name:'academic_level',
table: 'curso_ens_superior',
tableField: 'cod_grau_academico',
resultField: 'academic_level_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_grau_academico'
}
}).addValue({
name:'upper_education_mod',
table: 'curso_ens_superior',
tableField: 'cod_modalidade_ensino',
resultField: 'upper_education_mod_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_modalidade_ensino'
}
}).addValue({
name:'is_free',
table: 'curso_ens_superior',
tableField: 'gratuito',
resultField: 'is_free_id',
where: {
relation: '=',
type: 'boolean',
field: 'gratuito'
}
}).addValue({
name:'night_time',
table: 'curso_ens_superior',
tableField: 'noturno_curso',
resultField: 'night_time_id',
where: {
relation: '=',
type: 'boolean',
field: 'noturno_curso'
}
}).addValue({
name:'situation',
table: 'curso_ens_superior',
tableField: 'cod_situacao_curso',
resultField: 'situacao_curso_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_situacao_curso'
}
}).addValue({
name:'year',
table: 'curso_ens_superior',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '=',
type: 'integer',
field: 'ano_censo'
}
}).addValue({
name: 'min_year',
table: 'curso_ens_superior',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '>=',
type: 'integer',
table: 'curso_ens_superior',
field: 'ano_censo'
}
}).addValue({
name: 'max_year',
table: 'curso_ens_superior',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '<=',
type: 'integer',
table: 'curso_ens_superior',
field: 'ano_censo'
}
});
courseCountApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.from('curso_ens_superior')
.field('COUNT(curso_ens_superior.cod_curso)', 'total')
.field("'Brasil'", 'name')
.field('curso_ens_superior.ano_censo', 'year')
.group('curso_ens_superior.ano_censo')
.order('curso_ens_superior.ano_censo')
.where('curso_ens_superior.tipo_atributo_ingresso <> 1')
.where('curso_ens_superior.cod_nivel_academico = 1');
next();
}, query, addMissing(rqf), id2str.transform(), response('course_count'));
module.exports = courseCountApp;
/*
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 enrollmentApp = express.Router(); const enrollmentApp = express.Router();
...@@ -18,10 +38,6 @@ const id2str = require(`${libs}/middlewares/id2str`); ...@@ -18,10 +38,6 @@ const id2str = require(`${libs}/middlewares/id2str`);
const config = require(`${libs}/config`); const config = require(`${libs}/config`);
const passport = require('passport');
const download = require(`${libs}/middlewares/downloadDatabase`);
const addMissing = require(`${libs}/middlewares/addMissing`); const addMissing = require(`${libs}/middlewares/addMissing`);
const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware; const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
...@@ -398,6 +414,31 @@ rqf.addField({ ...@@ -398,6 +414,31 @@ rqf.addField({
foreign: ['escola_id', 'ano_censo'], foreign: ['escola_id', 'ano_censo'],
foreignTable: 'matricula' foreignTable: 'matricula'
} }
}, 'dims').addValueToField({
name: 'locale_id',
table: 'matricula',
tableField: 'localizacao_id',
resultField: 'locale_id',
where: {
relation: '=',
type: 'integer',
field: 'localizacao_id'
}
}, 'dims').addValueToField({
name: 'school_id',
table: 'escola',
tableField: 'id',
resultField: 'school_id',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: ['id', 'ano_censo'],
foreign: ['escola_id', 'ano_censo'],
foreignTable: 'matricula'
}
}, 'dims').addValueToField({ }, 'dims').addValueToField({
name: 'school', name: 'school',
table: 'escola', table: 'escola',
...@@ -490,7 +531,7 @@ rqf.addField({ ...@@ -490,7 +531,7 @@ rqf.addField({
resultField: 'integral_time_id', resultField: 'integral_time_id',
where: { where: {
relation: '=', relation: '=',
type: 'boolean', type: 'integer',
field: 'tempo_integral' field: 'tempo_integral'
} }
}).addValue({ }).addValue({
...@@ -515,18 +556,15 @@ rqf.addField({ ...@@ -515,18 +556,15 @@ rqf.addField({
} }
}); });
enrollmentApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { enrollmentApp.get('/', rqf.parse(), (req, res, next) => {
req.sql.field('COUNT(*)', 'total') req.sql.field('COUNT(*)', 'total')
.field("'Brasil'", 'name')
.field('matricula.ano_censo', 'year') .field('matricula.ano_censo', 'year')
.from('matricula') .from('matricula')
.group('matricula.ano_censo') .group('matricula.ano_censo')
.order('matricula.ano_censo') .order('matricula.ano_censo')
.where('matricula.tipo<=3'); .where('matricula.tipo<=3');
next(); next();
}, query, addMissing(rqf), id2str.transform(false), response('enrollment')); }, rqf.build(), query, id2str.transform(false), addMissing(rqf), response('enrollment'));
enrollmentApp.get('/download', passport.authenticate('bearer', { session: false }), rqf.parse(), rqf.build(), download('matricula', 'mapping_matricula'));
enrollmentApp.get('/diagnosis', rqf.parse(), (req, res, next) => { enrollmentApp.get('/diagnosis', rqf.parse(), (req, res, next) => {
req.dims = {}; req.dims = {};
......
/*
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 universityEnrollmentApp = 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 ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
const id2str = require(`${libs}/middlewares/id2str`);
const addMissing = require(`${libs}/middlewares/addMissing`);
const config = require(`${libs}/config`);
const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
let rqf = new ReqQueryFields();
universityEnrollmentApp.get('/years', (req, res, next) => {
req.sql.from('aluno_ens_superior')
.field('DISTINCT aluno_ens_superior.ano_censo', 'year')
.where('aluno_ens_superior.ano_censo = 2017');
next();
}, query, response('years'));
universityEnrollmentApp.get('/year_range', (req, res, next) => {
req.sql.from('aluno_ens_superior')
.field('MIN(aluno_ens_superior.ano_censo)', 'start_year')
.field('MAX(aluno_ens_superior.ano_censo)', 'end_year');
next();
}, query, response('range'));
universityEnrollmentApp.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'));
universityEnrollmentApp.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'));
universityEnrollmentApp.get('/ocde_geral', (req, res, next) => {
req.result = [];
for(let i = 0; i <= 8; ++i) {
req.result.push({
id: i,
name: id2str.ocdeGeral(i)
});
};
next();
}, response('ocde_geral'));
universityEnrollmentApp.get('/ocde_specific', (req, res, next) => {
req.result = [];
const defaultCase = null;
for(let i = 1; i <= 86; ++i) {
let obj = {
id: i,
name: id2str.ocdeSpecific(i)
};
if (obj.name !== id2str.ocdeSpecific(defaultCase)){
req.result.push(obj);
}
};
req.result.push({
id: defaultCase,
name: id2str.ocdeSpecific(defaultCase)
});
next();
}, response('ocde_specific'));
universityEnrollmentApp.get('/ocde_detailed', (req, res, next) => {
req.result = [];
const defaultCase = null;
for(let i = 142; i <= 863; ++i) {
let obj = {
id: i,
name: id2str.ocdeDetailed(i)
};
if (obj.name !== id2str.ocdeDetailed(defaultCase)){
req.result.push(obj);
}
};
req.result.push({
id: defaultCase,
name: id2str.ocdeDetailed(defaultCase)
});
next();
}, response('ocde_detailed'));
universityEnrollmentApp.get('/upper_turn', (req, res, next) => {
req.result = [];
for(let i = 1; i <= 4; ++i) {
req.result.push({
id: i,
name: id2str.upperTurn(i)
});
};
next();
}, response('upper_turn'));
universityEnrollmentApp.get('/student_deficiency', (req, res, next) => {
req.result = [];
for(let i = 0; i <= 1; ++i) {
req.result.push({
id: i,
name: id2str.studentDeficiency(i)
});
};
next();
}, response('student_deficiency'));
universityEnrollmentApp.get('/ethnic_group_ies', (req, res, next) => {
req.result = [];
for(let i = 1; i <=5; ++i) {
req.result.push({
id: i,
name: id2str.ethnicGroupIES(i)
});
}
next();
}, response('ethnic_group_ies'));
universityEnrollmentApp.get('/school_type', (req, res, next) => {
req.result = [];
for(let i = 1; i <= 2; ++i) {
req.result.push({
id: i,
name: id2str.schoolType(i)
});
};
next();
}, response('school_type'));
universityEnrollmentApp.get('/university', (req, res, next) => {
req.sql.from('aluno_ens_superior')
.field('DISTINCT aluno_ens_superior.nome_ies', 'nome')
.field('aluno_ens_superior.cod_ies', 'cod')
next();
}, query, response('university'));
universityEnrollmentApp.get('/academic_level', (req, res, next) => {
req.result = [];
for(let i = 1; i <= 4; ++i) {
req.result.push({
id: i,
name: id2str.academicLevel(i)
});
};
next();
}, response('academic_level'));
universityEnrollmentApp.get('/gender_ies', function (req, res, next) {
req.result = [];
for (var i = 1; i <= 2; ++i) {
req.result.push({
id: i,
name: id2str.genderIES(i)
});
};
next();
}, response('gender_ies'));
universityEnrollmentApp.get('/upper_education_mod', function (req, res, next) {
req.result = [];
for (var i = 1; i <= 3; ++i) {
req.result.push({
id: i,
name: id2str.upperEducationMod(i)
});
};
next();
}, response('upper_education_mod'));
universityEnrollmentApp.get('/age_student_code', function (req, res, next) {
req.result = [];
for (var i = 1; i <= 6; ++i) {
req.result.push({
id: i,
name: id2str.ageStudentCode(i)
});
};
next();
}, response('age_student_code'));
rqf.addField({
name: 'filter',
field: false,
where: true
}).addField({
name: 'dims',
field: true,
where: false
}).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: 'city',
table: 'municipio',
tableField: ['nome', 'id'],
resultField: ['city_name', 'city_id'],
where: {
relation: '=',
type: 'integer',
field: 'cod_municipio_ies',
table: '@'
},
join: {
primary: 'id',
foreign: 'cod_municipio_ies',
foreignTable: '@'
}
}).addValue({
name: 'region',
table: 'regiao',
tableField: ['nome', 'id'],
resultField: ['region_name', 'region_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'cod_regiao_ies',
foreignTable: 'aluno_ens_superior'
}
}).addValue({
name: 'university',
table: 'aluno_ens_superior',
tableField: ['cod_ies', 'nome_ies'],
resultField: ['university_id', 'university_name'],
where: {
relation: '=',
type: 'integer',
field: 'cod_ies'
}
}).addValue({
name: 'age_student_code',
table: 'aluno_ens_superior',
tableField: 'idade_aluno_codigo',
resultField: 'age_student_code_id',
where: {
relation: '=',
type: 'integer',
field: 'idade_aluno_codigo'
}
}).addValue({
name: 'upper_adm_dependency',
table: 'aluno_ens_superior',
tableField: 'cod_categoria_administrativa',
resultField: 'upper_adm_dependency_id',
where: {
relation: '=',
type: 'integer',
table: 'aluno_ens_superior',
field: 'cod_categoria_administrativa'
}
}).addValue({
name: 'academic_organization',
table: 'aluno_ens_superior',
tableField: 'cod_organizacao_academica',
resultField: 'academic_organization_id',
where: {
relation: '=',
type: 'integer',
table: 'aluno_ens_superior',
field: 'cod_organizacao_academica'
}
}).addValue({
name:'ocde_specific',
table: 'aluno_ens_superior',
tableField: 'cod_ocde_area_especifica',
resultField: 'ocde_specific_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_ocde_area_especifica'
}
}).addValue({
name:'ocde_geral',
table: 'aluno_ens_superior',
tableField: 'cod_ocde_area_geral',
resultField: 'ocde_geral_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_ocde_area_geral'
}
}).addValue({
name:'ocde_detailed',
table: 'aluno_ens_superior',
tableField: 'cod_ocde_area_detalhada',
resultField: 'ocde_detailed_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_ocde_area_detalhada'
}
}).addValue({
name:'academic_level',
table: 'aluno_ens_superior',
tableField: 'cod_grau_academico',
resultField: 'academic_level_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_grau_academico'
}
}).addValue({
name:'upper_education_mod',
table: 'aluno_ens_superior',
tableField: 'cod_modalidade_ensino',
resultField: 'upper_education_mod_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_modalidade_ensino'
}
}).addValue({
name:'upper_turn',
table: 'aluno_ens_superior',
tableField: 'cod_turno_aluno',
resultField: 'upper_turn_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_turno_aluno'
}
}).addValue({
name:'ethnic_group_ies',
table: 'aluno_ens_superior',
tableField: 'cod_cor_raca_aluno',
resultField: 'ethnic_group_ies_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_cor_raca_aluno'
}
}).addValue({
name:'student_deficiency',
table: 'aluno_ens_superior',
tableField: 'aluno_deficiencia_transtorno_superdotacao',
resultField: 'student_deficiency_id',
where: {
relation: '=',
type: 'integer',
field: 'aluno_deficiencia_transtorno_superdotacao'
}
}).addValue({
name:'school_type',
table: 'aluno_ens_superior',
tableField: 'tipo_escola_ensino_medio',
resultField: 'school_type_id',
where: {
relation: '=',
type: 'integer',
field: 'tipo_escola_ensino_medio'
}
}).addValue({
name: 'university',
table: 'aluno_ens_superior',
tableField: ['cod_ies', 'nome_ies'],
resultField: ['university_id', 'university_name'],
where: {
relation: '=',
type: 'integer',
field: 'cod_ies'
}
}).addValue({
name: 'gender_ies',
table: 'aluno_ens_superior',
tableField: 'genero_aluno',
resultField: 'gender_ies_id',
where: {
relation: '=',
type: 'integer',
field: 'genero_aluno'
}
}).addValue({
name:'academic_level',
table: 'aluno_ens_superior',
tableField: 'cod_grau_academico',
resultField: 'academic_level_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_grau_academico'
}
});
universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => {
req.sql.field('COUNT(*)', 'total')
.field("'Brasil'", 'name')
.field('aluno_ens_superior.ano_censo', 'year')
.from('aluno_ens_superior')
.where('aluno_ens_superior.matriculado = 1 AND aluno_ens_superior.cod_nivel_academico = 1')
.group('aluno_ens_superior.ano_censo')
.order('aluno_ens_superior.ano_censo')
next();
}, rqf.build(), query, addMissing(rqf), id2str.transform(false), response('universityEnrollment'));
module.exports = universityEnrollmentApp;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment