diff --git a/src/libs/routes/enrollment.js b/src/libs/routes/enrollment.js index a52451d7ef423a907494eb4f3963b43c277e1ace..cddfda064fd1450195fed4a799e353b672a05051 100644 --- a/src/libs/routes/enrollment.js +++ b/src/libs/routes/enrollment.js @@ -317,23 +317,20 @@ enrollmentApp.get('/offer_projection', simRqf.parse(), simRqf.build(), (req, res .from('matricula') .toString(); - req.sql.field('matricula.ano_censo', 'offerYear') - .field('turma.turno', 'period_id') + req.sql.field('uc408.ano_censo', 'offerYear') + .field('uc408.turma_turno_id', 'period_id') .field('etapa_ensino.desc_etapa', 'education_level_name') .field('etapa_ensino.id', 'education_level_id') - .field('matricula.serie_ano_id', 'school_year_id') - .field('COUNT(matricula.id)', 'currentOffer') - .from('matricula') - .join('etapa_ensino', null, 'matricula.etapa_ensino_id=etapa_ensino.id') - .join('turma', null, 'matricula.turma_id=turma.id') - .where('matricula.tipo <= 3') - .where(`matricula.ano_censo IN (${max_year})`) - .where('turma.turno <= 2') - .group('matricula.ano_censo') - .group('turma.turno') + .field('uc408.serie_ano_id', 'school_year_id') + .field('SUM(uc408.matriculas)', 'currentOffer') + .from('uc408') + .join('etapa_ensino', null, 'uc408.etapas_mod_ensino_segmento_id=etapa_ensino.id') + .where('uc408.turma_turno_id <= 2') + .group('uc408.ano_censo') + .group('uc408.turma_turno_id') .group('etapa_ensino.desc_etapa') .group('etapa_ensino.id') - .group('matricula.serie_ano_id'); + .group('uc408.serie_ano_id'); next(); }, query, id2str.transform(false), (req, res, next) => { @@ -357,11 +354,11 @@ enrollmentApp.get('/offer_projection', simRqf.parse(), simRqf.build(), (req, res 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({ id: i.school_year_id, name: i.school_year_name, - currentOffer: i.currentOffer + currentOffer: parseInt(i.currentOffer, 10) }); }); Object.keys(temp.daytime).forEach((k) => {