Skip to content
Snippets Groups Projects
Commit 078cad7f authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Add enrollment per school level and adm dependency in /spatial/educational

parent d2735617
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!34Db simcaq dev2
Pipeline #
...@@ -356,10 +356,30 @@ spatialApp.get('/educational', rqf.parse(), rqf.build(), (req, res, next) => { ...@@ -356,10 +356,30 @@ spatialApp.get('/educational', rqf.parse(), rqf.build(), (req, res, next) => {
.order('ano_censo') .order('ano_censo')
.order('localizacao.descricao'); .order('localizacao.descricao');
const enrollmentsPerSchoolLevelAndAdmDependencyQry = req.sql.clone()
.field('\'Brasil\'', 'name')
.field('COALESCE(COUNT(matricula.id), 0)', 'total')
.field('matricula.ano_censo', 'census_year')
.field('etapa_ensino.desc_etapa', 'school_level_name')
.field('dependencia_adm.nome', 'adm_dependency_name')
.from('etapa_ensino')
.from('dependencia_adm')
.from('matricula')
.where('matricula.etapa_ensino_id=etapa_ensino.id')
.where('matricula.dependencia_adm_id=dependencia_adm.id')
.where('matricula.tipo <= 3')
.where(`matricula.ano_censo IN (${schoolClassYearQry})`)
.group('matricula.ano_censo')
.group('etapa_ensino.desc_etapa')
.group('dependencia_adm.nome')
.order('matricula.ano_censo')
.order('etapa_ensino.desc_etapa')
.order('dependencia_adm.nome');
const queryLabels = [ "school", "school_per_location", "school_per_adm_dependency", "enrollment", "enrollment_per_adm_dep", const queryLabels = [ "school", "school_per_location", "school_per_adm_dependency", "enrollment", "enrollment_per_adm_dep",
"enrollment_per_school_level", "enrollment_per_location" ]; "enrollment_per_school_level", "enrollment_per_location", "enrollment_per_school_level_adm_dependency" ];
const querySet = [ totalSchoolsQry, schoolsPerLocationQry, schoolsPerAdmDependencyQry, enrollmentsQry, const querySet = [ totalSchoolsQry, schoolsPerLocationQry, schoolsPerAdmDependencyQry, enrollmentsQry,
enrollmentsPerAdmDepQry, enrollmentsPerSchoolLevelQry, enrollmentsPerLocationQry]; enrollmentsPerAdmDepQry, enrollmentsPerSchoolLevelQry, enrollmentsPerLocationQry, enrollmentsPerSchoolLevelAndAdmDependencyQry];
// wait until all queries finish or one of them fail // wait until all queries finish or one of them fail
Promise.all(dbExecAll(querySet)).then((queryResults) => { Promise.all(dbExecAll(querySet)).then((queryResults) => {
req.result = processResultSet(queryResults, queryLabels); req.result = processResultSet(queryResults, queryLabels);
......
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