Commit b6916c1e authored by Vytor Calixto's avatar Vytor Calixto 👾

Basic formatting

parent df675691
Pipeline #14993 failed with stage
in 5 minutes and 43 seconds
...@@ -39,12 +39,12 @@ rqf.addField({ ...@@ -39,12 +39,12 @@ rqf.addField({
relation: '=', relation: '=',
type: 'integer', type: 'integer',
field: 'municipio_id', field: 'municipio_id',
table: 'matricula' table: '@'
}, },
join: { join: {
primary: 'id', primary: 'id',
foreign: 'municipio_id', foreign: 'municipio_id',
foreignTable: 'matricula' foreignTable: '@'
} }
}, 'filter').addValueToField({ }, 'filter').addValueToField({
name: 'city', name: 'city',
...@@ -59,9 +59,9 @@ rqf.addField({ ...@@ -59,9 +59,9 @@ rqf.addField({
join: { join: {
primary: 'id', primary: 'id',
foreign: 'municipio_id', foreign: 'municipio_id',
foreignTable: 'matricula' foreignTable: '@'
} }
}, 'dims').addValue({ }, 'dims').addValueToField({
name: 'state', name: 'state',
table: 'estado', table: 'estado',
tableField: 'nome', tableField: 'nome',
...@@ -70,14 +70,29 @@ rqf.addField({ ...@@ -70,14 +70,29 @@ rqf.addField({
relation: '=', relation: '=',
type: 'integer', type: 'integer',
field: 'estado_id', field: 'estado_id',
table: 'matricula' table: '@'
}, },
join: { join: {
primary: 'id', primary: 'id',
foreign: 'estado_id', foreign: 'estado_id',
foreignTable: 'matricula' foreignTable: '@'
} }
}).addValue({ }, 'filter').addValueToField({
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: '@'
}
}, 'dims').addValue({
name: 'region', name: 'region',
table: 'regiao', table: 'regiao',
tableField: 'nome', tableField: 'nome',
...@@ -90,11 +105,11 @@ rqf.addField({ ...@@ -90,11 +105,11 @@ rqf.addField({
join: { join: {
primary: 'id', primary: 'id',
foreign: 'regiao_id', foreign: 'regiao_id',
foreignTable: 'matricula' foreignTable: '@'
} }
}).addValue({ }).addValue({
name: 'min_year', name: 'min_year',
table: 'matricula', table: '@',
tableField: 'ano_censo', tableField: 'ano_censo',
resultField: 'year', resultField: 'year',
where: { where: {
...@@ -104,7 +119,7 @@ rqf.addField({ ...@@ -104,7 +119,7 @@ rqf.addField({
} }
}).addValue({ }).addValue({
name: 'max_year', name: 'max_year',
table: 'matricula', table: '@',
tableField: 'ano_censo', tableField: 'ano_censo',
resultField: 'year', resultField: 'year',
where: { where: {
...@@ -114,7 +129,7 @@ rqf.addField({ ...@@ -114,7 +129,7 @@ rqf.addField({
} }
}).addValue({ }).addValue({
name: 'period', name: 'period',
table: 'matricula', table: '@',
tableField: 'turma_turno_id', tableField: 'turma_turno_id',
resultField: 'period_id', resultField: 'period_id',
where: { where: {
...@@ -124,7 +139,7 @@ rqf.addField({ ...@@ -124,7 +139,7 @@ rqf.addField({
} }
}).addValue({ }).addValue({
name: 'school_year', name: 'school_year',
table: 'matricula', table: '@',
tableField: 'serie_ano_id', tableField: 'serie_ano_id',
resultField: 'school_year_id', resultField: 'school_year_id',
where: { where: {
...@@ -134,7 +149,7 @@ rqf.addField({ ...@@ -134,7 +149,7 @@ rqf.addField({
} }
}).addValue({ }).addValue({
name: 'location', name: 'location',
table: 'matricula', table: '@',
tableField: 'localizacao_id', tableField: 'localizacao_id',
resultField: 'location_id', resultField: 'location_id',
where: { where: {
...@@ -144,7 +159,7 @@ rqf.addField({ ...@@ -144,7 +159,7 @@ rqf.addField({
} }
}).addValue({ }).addValue({
name: 'education_level_short', name: 'education_level_short',
table: 'matricula', table: '@',
tableField: 'etapa_resumida', tableField: 'etapa_resumida',
resultField: 'education_level_short_id', resultField: 'education_level_short_id',
where: { where: {
...@@ -155,14 +170,6 @@ rqf.addField({ ...@@ -155,14 +170,6 @@ rqf.addField({
}); });
classroomCountApp.post('/', rqf.parse(), (req, res, next) => { classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
console.log('body');
console.log(req.body);
let classSize = JSON.parse(req.body.class_size) || null;
let integralTime = JSON.parse(req.body.integral_time) || null;
console.log(classSize, integralTime);
req.dims.state = true; req.dims.state = true;
req.dims.city = true; req.dims.city = true;
req.dims.period = true; req.dims.period = true;
...@@ -179,11 +186,84 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => { ...@@ -179,11 +186,84 @@ classroomCountApp.post('/', rqf.parse(), (req, res, next) => {
next(); next();
}, rqf.build(), query, id2str.transform(), (req, res, next) => { }, rqf.build(), query, id2str.transform(), (req, res, next) => {
let result = req.result; req.enrollment = req.result;
// result.forEach((r) => { req.resetSql();
next();
}, rqf.parse(), (req, res, next) => {
req.dims.state = true;
req.dims.city = true;
req.dims.location = true;
req.sql.field('SUM(escola.num_salas)', 'total')
.field("'Brasil'", 'name')
.field('escola.ano_censo', 'year')
.from('escola')
.group('escola.ano_censo')
.order('escola.ano_censo')
.where('escola.situacao_de_funcionamento = 1 AND escola.local_func_predio_escolar = 1');
next();
}, rqf.build(), query, id2str.transform(), (req, res, next) => {
let classSize = JSON.parse(req.body.class_size) || null;
let integralTime = JSON.parse(req.body.integral_time) || null;
// }); console.log(classSize, integralTime);
req.classroom = req.result;
let classroom = [];
req.classroom.forEach((c) => {
let cityObjects = req.classroom.filter((value) => {
return (c.city_id == value.city_id && c.year == value.year);
});
let obj = {
state_id: c.state_id,
state_name: c.state_name,
city_id: c.city_id,
city_name: c.city_name,
year: c.year,
locations: []
};
cityObjects.forEach((co) => {
obj.locations.push({
location_id: co.location_id,
location_name: co.location_name,
total_classroom: co.total
});
});
if(classroom.findIndex((el) => {return el.city_id === obj.city_id}) === -1) {
classroom.push(obj);
}
});
let result = [];
classroom.forEach((c) => {
function filterUrbanEnrollment(e) {
return (e.city_id == c.city_id && e.year == c.year && e.location_id == 1);
}
function filterRuralEnrollment(e) {
return (e.city_id == c.city_id && e.year == c.year && e.location_id == 2);
}
let urbanEnrollments = req.enrollment.filter(filterUrbanEnrollment);
let ruralEnrollments = req.enrollment.filter(filterRuralEnrollment);
let r = c;
// r.locations[0].enrollments = urbanEnrollments;
// r.locations[1].enrollments = ruralEnrollments;
result.push(r);
});
console.log('FEITO');
// console.log('SALAS');
// console.log(classroom[0]);
// console.log('FILTRO');
// console.log(classEnrollments);
req.result = result;
next(); next();
}, response('classroom_count')); }, response('classroom_count'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment