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

Parcial correct indicator

parent beabfdd6
No related branches found
No related tags found
No related merge requests found
Pipeline #17812 failed
...@@ -247,6 +247,166 @@ rqfSchool.addField({ ...@@ -247,6 +247,166 @@ rqfSchool.addField({
} }
}); });
rqfTeacher.addField({
name: 'filter',
field: false,
where: true
}).addField({
name: 'dims',
field: true,
where: false
}).addValue({
name: 'adm_dependency',
table: '@',
tableField: 'dependencia_adm_id',
resultField: 'adm_dependency_id',
where: {
relation: '=',
type: 'integer',
field: 'dependencia_adm_id'
}
}).addValue({
name: 'adm_dependency_detailed',
table: '@',
tableField: 'dependencia_adm_priv',
resultField: 'adm_dependency_detailed_id',
where: {
relation: '=',
type: 'integer',
field: 'dependencia_adm_priv'
}
}).addValue({
name: 'region',
table: 'regiao',
tableField: 'nome',
resultField: 'region_name',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'regiao_id',
foreignTable: '@'
}
}).addValue({
name: 'state',
table: 'estado',
tableField: 'nome',
resultField: 'state_name',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'estado_id',
foreignTable: '@'
}
}).addValueToField({
name: 'city',
table: 'municipio',
tableField: ['nome', 'id'],
resultField: ['city_name', 'city_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'municipio_id',
foreignTable: '@'
}
}, 'dims').addValueToField({
name: 'city',
table: 'municipio',
tableField: 'nome',
resultField: 'city_name',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'municipio_id',
foreignTable: '@'
}
}, 'filter').addValueToField({
name: 'school',
table: 'escola',
tableField: ['nome_escola', 'id'],
resultField: ['school_name', 'school_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: ['id','ano_censo'],
foreign: ['id','ano_censo'],
foreignTable: '@'
}
}, 'dims').addValueToField({
name: 'school',
table: 'escola',
tableField: 'nome_escola',
resultField: 'school_name',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: ['id','ano_censo'],
foreign: ['id','ano_censo'],
foreignTable: '@'
}
}, 'filter').addValue({
name: 'location',
table: '@',
tableField: 'cod_localizacao',
resultField: 'location_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_localizacao'
}
}).addValue({
name: 'rural_location',
table: '@',
tableField: 'localidade_area_rural',
resultField: 'rural_location_id',
where: {
relation: '=',
type: 'integer',
field: 'localidade_area_rural'
}
}).addValue({
name: 'min_year',
table: '@',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '>=',
type: 'integer',
field: 'ano_censo'
}
}).addValue({
name: 'max_year',
table: '@',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '<=',
type: 'integer',
field: 'ano_censo'
}
});
function matchQueries(queryTotal, queryPartial) { function matchQueries(queryTotal, queryPartial) {
let match = []; let match = [];
...@@ -317,21 +477,21 @@ employeesApp.get('/', rqfSchool.parse(), (req, res, next) => { ...@@ -317,21 +477,21 @@ employeesApp.get('/', rqfSchool.parse(), (req, res, next) => {
req.resetSql(); req.resetSql();
if ("school" in req.filter) { if ("school" in req.filter) {
req.sql.field('SUM(professor_por_escola.total_professores)', 'total') req.sql.field('SUM(docente_por_escola.total_professores)', 'total')
.field("'Brasil'", 'name') .field("'Brasil'", 'name')
.field('professor_por_escola.ano_censo', 'year') .field('docente_por_escola.ano_censo', 'year')
.from('professor_por_escola') .from('docente_por_escola')
.group('professor_por_escola.ano_censo') .group('docente_por_escola.ano_censo')
.order('professor_por_escola.ano_censo') .order('docente_por_escola.ano_censo')
.where('(professor_por_escola.dependencia_adm_id > 1) AND (escola.id=' + req.filter.school + ')'); .where('(docente_por_escola.dependencia_adm_id > 1) AND (docente_por_escola.id=' + req.filter.school + ')');
} else { } else {
req.sql.field('SUM(professor_por_escola.total_professores)', 'total') req.sql.field('SUM(docente_por_escola.total_professores)', 'total')
.field("'Brasil'", 'name') .field("'Brasil'", 'name')
.field('professor_por_escola.ano_censo', 'year') .field('docente_por_escola.ano_censo', 'year')
.from('professor_por_escola') .from('docente_por_escola')
.group('professor_por_escola.ano_censo') .group('docente_por_escola.ano_censo')
.order('professor_por_escola.ano_censo') .order('docente_por_escola.ano_censo')
.where('(professor_por_escola.dependencia_adm_id > 1)'); .where('(docente_por_escola.dependencia_adm_id > 1)');
} }
next(); next();
......
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