Skip to content
Snippets Groups Projects
Commit 959f9a12 authored by lgtg20's avatar lgtg20
Browse files

integral_time filter working

parent 85fb6066
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
...@@ -5,12 +5,13 @@ const convert = { ...@@ -5,12 +5,13 @@ const convert = {
"age_range": "ageRangeAggregate", "age_range": "ageRangeAggregate",
"gender": "gender", "gender": "gender",
"ethnic_group": "ethnicGroup", "ethnic_group": "ethnicGroup",
"education_level_mod_agg": "educationLevelModAgg" "education_level_mod_agg": "educationLevelModAgg",
'integral_time_agg': 'integralTime'
} }
function aggregateData(req, res, next) { function aggregateData(req, res, next) {
const newResult = [] const newResult = []
const aggregateFields = ['gender', 'age_range', 'ethnic_group', 'education_level_mod_agg'] const aggregateFields = ['gender', 'age_range', 'ethnic_group', 'education_level_mod_agg', 'integral_time_agg']
let id; let id;
const fields = req.query.dims.split(','); const fields = req.query.dims.split(',');
let currentAggregateField; let currentAggregateField;
...@@ -19,7 +20,7 @@ function aggregateData(req, res, next) { ...@@ -19,7 +20,7 @@ function aggregateData(req, res, next) {
if (currentAggregateField) { if (currentAggregateField) {
console.log(currentAggregateField); console.log(currentAggregateField);
req.result.forEach((r) => { req.result.forEach((r) => {
id = currentAggregateField === 'ethnic_group' ? 0 : 1; id = ['ethnic_group', 'integral_time_agg'].includes(currentAggregateField) ? 0 : 1;
for (const property in r) { for (const property in r) {
if (property.includes("total_")) { if (property.includes("total_")) {
let data = { let data = {
......
...@@ -355,6 +355,17 @@ enrollmentAggregateApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { ...@@ -355,6 +355,17 @@ enrollmentAggregateApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
.group('escola.ano_censo') .group('escola.ano_censo')
.order('escola.ano_censo'); .order('escola.ano_censo');
} }
else if (req.query.dims && req.query.dims.includes('integral_time_agg')) {
req.sql.from('turma,escola')
.field('SUM(CASE WHEN turma.tempo_integral=0 then turma.num_matricula ELSE 0 END)', 'total_int_nao')
.field('SUM(CASE WHEN turma.tempo_integral=1 then turma.num_matricula ELSE 0 END)', 'total_int')
.field('SUM(CASE WHEN turma.tempo_integral=2 then turma.num_matricula ELSE 0 END)', 'total_int_nao_aplica')
.field('escola.ano_censo', 'year')
.group('escola.ano_censo')
.order('escola.ano_censo')
.where('turma.tipo_atendimento_id <= 2 and turma.escola_id = escola.id and turma.ano_censo = escola.ano_censo');
}
else { else {
req.sql.from('escola') req.sql.from('escola')
.field('SUM(escola.qt_mat_bas)', 'total') .field('SUM(escola.qt_mat_bas)', 'total')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment