Skip to content
Snippets Groups Projects
Commit 85fb6066 authored by lgtg20's avatar lgtg20
Browse files

Almost finished

parent 95c251ef
No related branches found
No related tags found
3 merge requests!417[ADD] Indicator "Taxa de Atendimento Educacional" updated on production!,!416[ADD] Route almost ready, some tests needed. Comments added and filters that...,!410Aggregate enrollment
/*
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 ageRangeAggregate(id) {
switch (id) {
case 1:
return '0 a 3 anos';
case 2:
return '4 a 5 anos';
case 3:
return '6 a 10 anos';
case 4:
return '11 a 14 anos';
case 5:
return '15 a 17 anos';
case 6:
return '18 anos ou mais';
default:
return 'Não declarada';
}
};
/*
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 educationLevelMod(id) {
switch (id) {
case 1:
return 'Creche';
case 2:
return 'Pré-Escola';
case 3:
return 'Ensino Fundamental - anos iniciais';
case 4:
return 'Ensino Fundamental - anos finais';
case 5:
return 'Ensino Médio';
case 6:
return 'Ensino Medio Integrado ou Normal - tecnico';
case 7:
return 'EJA - Ensino Fundamental';
case 8:
return 'EJA - Ensino Médio';
case 9:
return 'EJA - EF e EM Integrado - tecnico';
case 10:
return 'Educacao Profissional - concomitante e subsequente';
default:
return 'Não classificada';
}
};
const id2str = require(`./id2str`);
const convert = {
"adm_dependency_detailed": "admDependencyPriv"
"adm_dependency_detailed": "admDependencyPriv",
"age_range": "ageRangeAggregate",
"gender": "gender",
"ethnic_group": "ethnicGroup",
"education_level_mod_agg": "educationLevelModAgg"
}
function aggregateData(req, res, next) {
const newResult = []
const aggregateFields = ['gender']
const aggregateFields = ['gender', 'age_range', 'ethnic_group', 'education_level_mod_agg']
let id;
const fields = req.query.dims.split(',');
let currentAggregateField;
......@@ -15,14 +19,14 @@ function aggregateData(req, res, next) {
if (currentAggregateField) {
console.log(currentAggregateField);
req.result.forEach((r) => {
id = 1;
id = currentAggregateField === 'ethnic_group' ? 0 : 1;
for (const property in r) {
if (property.includes("total_")) {
let data = {
total: r[property],
year: r.year,
[`${currentAggregateField}_id`]: id,
[`${currentAggregateField}_name`]: id2str[currentAggregateField](id)
[`${currentAggregateField}_name`]: id2str[convert[currentAggregateField]](id)
}
if (currentNonAggregateField) {
......
......@@ -32,6 +32,7 @@ const agreement = require(`${libs}/convert/agreement`);
const booleanVariable = require(`${libs}/convert/booleanVariable`);
const educationLevel = require(`${libs}/convert/educationLevel`);
const educationLevelMod = require(`${libs}/convert/educationLevelMod`);
const educationLevelModAgg = require(`${libs}/convert/educationLevelModAgg`);
const educationLevelShort = require(`${libs}/convert/educationLevelShort`);
const educationType = require(`${libs}/convert/educationType`);
const citySize = require(`${libs}/convert/citySize`);
......@@ -114,6 +115,8 @@ const regionCode = require(`${libs}/convert/regionCode`);
const metroCode = require(`${libs}/convert/metroCode`);
const modalityShift = require(`${libs}/convert/modalityShift`);
const incomeRange = require(`${libs}/convert/incomeRange`);
const ageRangeAggregate = require(`${libs}/convert/ageRangeAggregate`);
const ids = {
gender_id: gender,
......@@ -122,6 +125,7 @@ const ids = {
education_level_id: educationLevel,
education_level_basic_id: educationLevelBasic,
education_level_mod_id: educationLevelMod,
education_level_mod_agg_id: educationLevelModAgg,
education_level_short_id: educationLevelShort,
adm_dependency_id: admDependency,
adm_dependency_detailed_id: admDependencyPriv,
......@@ -149,6 +153,7 @@ const ids = {
ethnic_group_pnad_id: ethnicGroupPnad,
age_range_id: ageRange,
age_range_all_id: ageRangeAll,
age_range_aggregate_id: ageRangeAggregate,
full_age_range_id: fullAgeRange,
gender_pnad_id: genderPnad,
fifth_household_income_id: fifthHouseholdIncome,
......@@ -267,6 +272,7 @@ module.exports = {
educationLevel,
educationLevelBasic,
educationLevelMod,
educationLevelModAgg,
educationLevelShort,
educationLevelSchoolYear,
admDependency,
......@@ -284,6 +290,7 @@ module.exports = {
contractType,
ethnicGroupPnad,
ageRange,
ageRangeAggregate,
ageRangeAll,
ageStudentCode,
fullAgeRange,
......
......@@ -88,6 +88,16 @@ rqf.addField({
field: 'etapas_mod_ensino_segmento_id'
}
}).addValue({
name:'integral_time',
table: 'escola',
tableField: 'tempo_integral',
resultField: 'integral_time_id',
where: {
relation: '=',
type: 'integer',
field: 'tempo_integral'
}
}).addValue({
name: 'education_level_short',
table: 'escola',
tableField: 'etapa_resumida',
......@@ -305,6 +315,46 @@ enrollmentAggregateApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.group('escola.ano_censo')
.order('escola.ano_censo');
}
else if (req.query.dims && req.query.dims.includes('age_range')) {
req.sql.from('escola')
.field('SUM(escola.qt_mat_bas_0_3)', 'total_0_3')
.field('SUM(escola.qt_mat_bas_4_5)', 'total_4_5')
.field('SUM(escola.qt_mat_bas_6_10)', 'total_6_10')
.field('SUM(escola.qt_mat_bas_11_14)', 'total_11_14')
.field('SUM(escola.qt_mat_bas_15_17)', 'total_15_17')
.field('SUM(escola.qt_mat_bas_18_mais)', 'total_18_mais')
.field('escola.ano_censo', 'year')
.group('escola.ano_censo')
.order('escola.ano_censo');
}
else if (req.query.dims && req.query.dims.includes('ethnic_group')) {
req.sql.from('escola')
.field('SUM(escola.qt_mat_bas_nd)', 'total_nd')
.field('SUM(escola.qt_mat_bas_branca)', 'total_branca')
.field('SUM(escola.qt_mat_bas_preta)', 'total_preta')
.field('SUM(escola.qt_mat_bas_parda)', 'total_parda')
.field('SUM(escola.qt_mat_bas_amarela)', 'total_amarela')
.field('SUM(escola.qt_mat_bas_indigena)', 'total_indigena')
.field('escola.ano_censo', 'year')
.group('escola.ano_censo')
.order('escola.ano_censo');
}
else if (req.query.dims && req.query.dims.includes('education_level_mod_agg')) {
req.sql.from('escola')
.field('SUM(escola.qt_mat_inf_cre)', 'total_cre')
.field('SUM(escola.qt_mat_inf_pre)', 'total_pre')
.field('SUM(escola.qt_mat_fund_ai)', 'total_fund_ai')
.field('SUM(escola.qt_mat_fund_af)', 'total_fund_af')
.field('SUM(escola.qt_mat_med_agg)', 'total_med')
.field('SUM(escola.qt_mat_med_ct + escola.qt_mat_med_nm)', 'total_med_in')
.field('SUM(escola.qt_mat_eja_fund_agg)', 'total_eja_fund')
.field('SUM(escola.qt_mat_eja_med_agg)', 'total_eja_med')
.field('SUM(escola.qt_mat_eja_fund_fic + escola.qt_mat_eja_med_fic + escola.qt_mat_eja_med_tec)', 'total_tec')
.field('SUM(escola.qt_mat_prof_agg)', 'total_prof')
.field('escola.ano_censo', 'year')
.group('escola.ano_censo')
.order('escola.ano_censo');
}
else {
req.sql.from('escola')
.field('SUM(escola.qt_mat_bas)', 'total')
......
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