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

:racehorse: Change table in /enrollment/offer_projection to go FASTER

parent ef2be1c4
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!44Feature multiple where
Pipeline #
...@@ -317,23 +317,20 @@ enrollmentApp.get('/offer_projection', simRqf.parse(), simRqf.build(), (req, res ...@@ -317,23 +317,20 @@ enrollmentApp.get('/offer_projection', simRqf.parse(), simRqf.build(), (req, res
.from('matricula') .from('matricula')
.toString(); .toString();
req.sql.field('matricula.ano_censo', 'offerYear') req.sql.field('uc408.ano_censo', 'offerYear')
.field('turma.turno', 'period_id') .field('uc408.turma_turno_id', 'period_id')
.field('etapa_ensino.desc_etapa', 'education_level_name') .field('etapa_ensino.desc_etapa', 'education_level_name')
.field('etapa_ensino.id', 'education_level_id') .field('etapa_ensino.id', 'education_level_id')
.field('matricula.serie_ano_id', 'school_year_id') .field('uc408.serie_ano_id', 'school_year_id')
.field('COUNT(matricula.id)', 'currentOffer') .field('SUM(uc408.matriculas)', 'currentOffer')
.from('matricula') .from('uc408')
.join('etapa_ensino', null, 'matricula.etapa_ensino_id=etapa_ensino.id') .join('etapa_ensino', null, 'uc408.etapas_mod_ensino_segmento_id=etapa_ensino.id')
.join('turma', null, 'matricula.turma_id=turma.id') .where('uc408.turma_turno_id <= 2')
.where('matricula.tipo <= 3') .group('uc408.ano_censo')
.where(`matricula.ano_censo IN (${max_year})`) .group('uc408.turma_turno_id')
.where('turma.turno <= 2')
.group('matricula.ano_censo')
.group('turma.turno')
.group('etapa_ensino.desc_etapa') .group('etapa_ensino.desc_etapa')
.group('etapa_ensino.id') .group('etapa_ensino.id')
.group('matricula.serie_ano_id'); .group('uc408.serie_ano_id');
next(); next();
}, query, id2str.transform(false), (req, res, next) => { }, query, id2str.transform(false), (req, res, next) => {
...@@ -357,11 +354,11 @@ enrollmentApp.get('/offer_projection', simRqf.parse(), simRqf.build(), (req, res ...@@ -357,11 +354,11 @@ enrollmentApp.get('/offer_projection', simRqf.parse(), simRqf.build(), (req, res
grades: [] grades: []
}; };
} }
temp[period][i.education_level_name].currentOffer += i.currentOffer; temp[period][i.education_level_name].currentOffer += parseInt(i.currentOffer, 10);
temp[period][i.education_level_name].grades.push({ temp[period][i.education_level_name].grades.push({
id: i.school_year_id, id: i.school_year_id,
name: i.school_year_name, name: i.school_year_name,
currentOffer: i.currentOffer currentOffer: parseInt(i.currentOffer, 10)
}); });
}); });
Object.keys(temp.daytime).forEach((k) => { Object.keys(temp.daytime).forEach((k) => {
......
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