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

Add school condition

parent bdfbf4a6
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -214,7 +214,7 @@ rqf.addField({
}
}, 'filter').addValue({
name: 'location',
table: 'docente',
table: '@',
tableField: 'cod_localizacao',
resultField: 'location_id',
where: {
......@@ -224,7 +224,7 @@ rqf.addField({
}
}).addValue({
name: 'rural_location',
table: 'docente',
table: '@',
tableField: 'localidade_area_rural',
resultField: 'rural_location_id',
where: {
......@@ -234,7 +234,7 @@ rqf.addField({
}
}).addValue({
name: 'min_year',
table: 'docente',
table: '@',
tableField: 'ano_censo',
resultField: 'year',
where: {
......@@ -244,7 +244,7 @@ rqf.addField({
}
}).addValue({
name: 'max_year',
table: 'docente',
table: '@',
tableField: 'ano_censo',
resultField: 'year',
where: {
......@@ -255,15 +255,54 @@ rqf.addField({
});
employeesApp.get('/', rqf.parse(), (req, res, next) => {
//let allEmployees = req.sql.clone()
req.sql.field('COUNT(escola.id)', 'total')
req.allEmployees = {}
req.allTeacher = {}
if ("school" in req.filter) {
req.sql.field('SUM(escola.num_funcionarios)', '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.ensino_regular = 1 OR escola.ensino_eja = 1 OR escola.educacao_profissional = 1) AND (dependencia_adm_id = 2 OR dependencia_adm_id = 3 OR dependencia_adm_id = 4) AND (escola.id=' + req.filter.school + ')');
delete req.filter.school;
next();
} else {
req.sql.field('SUM(escola.num_funcionarios)', '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.ensino_regular = 1 OR escola.ensino_eja = 1 OR escola.educacao_profissional = 1) AND (dependencia_adm_id = 2 OR dependencia_adm_id = 3 OR dependencia_adm_id = 4)');
next();
}
}, rqf.build(), query, rqf.parse(), id2str.transform(), (req, res, next) => {
req.allEmployees = req.result;
req.resetSql();
req.sql.field('COUNT(DISTINCT docente.id)', '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.ensino_regular = 1 OR escola.ensino_eja = 1 OR escola.educacao_profissional = 1) AND (dependencia_adm_id = 2 OR dependencia_adm_id = 3 OR dependencia_adm_id = 4)');
.field('docente.ano_censo', 'year')
.from('docente')
.join('turma', null, 'docente.turma_id=turma.id AND docente.ano_censo=turma.ano_censo')
.group('docente.ano_censo')
.order('docente.ano_censo')
.where('(docente.tipo_docente <= 6) AND (turma.tipo_turma_id <= 3)');
next();
}, rqf.build(), query, id2str.transform(), (req, res, next) => {
req.allTeacher = req.result;
req.result = []
req.result.push(req.allEmployees)
req.result.push(req.allTeacher)
console.log(req.allEmployees)
console.log(req.allTeacher)
next();
}, rqf.build(), query, response('employees'));
}, response('employees'));
module.exports = employeesApp;
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