From a226c872cf8bc16132da547927c1fb7b949e3e0b Mon Sep 17 00:00:00 2001 From: Victor Picussa <vic_picussa2@hotmail.com> Date: Tue, 7 Apr 2020 10:10:15 -0300 Subject: [PATCH] [v1.13.0]Added school and teacher --- CHANGELOG.md | 3 ++ src/libs/routes/school.js | 68 +++++++++++++++++++++++++++----------- src/libs/routes/teacher.js | 46 +++++++++++++++----------- 3 files changed, 77 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2347349..c5557c56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## 1.13.0 - 2020-04-XX ## Added - Added 2019 data +## Changed +- Updated 2007-2018 +- Updated education level mod ## 1.12.6 - 2020-02-02 ## Changed diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index ceb34f09..e430ff42 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -22,8 +22,6 @@ const config = require(`${libs}/config`); const passport = require('passport'); -const download = require(`${libs}/middlewares/downloadDatabase`); - const addMissing = require(`${libs}/middlewares/addMissing`); const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware; @@ -95,11 +93,13 @@ schoolApp.get('/adm_dependency_detailed', cache('15 day'), (req, res, next) => { }, response('adm_dependency_detailed')); schoolApp.get('/government_agreement', cache('15 day'), (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; + req.result = []; + for(let i = 1; i <= 6; ++i) { + req.result.push({ + id: i, + name: id2str.govermentAgreement(i) + }); + }; next(); }, response('government_agreement')); @@ -175,6 +175,16 @@ schoolApp.get('/education_eja', cache('15 day'), (req, res, next) => { next(); }, response('education_eja')); +schoolApp.get('/integral_time', cache('15 day'), (req, res, next) => { + req.result = [ + {id: 0, name: 'Não'}, + {id: 1, name: 'Sim'}, + {id: 2, name: 'Não se aplica - Semipresencial e EaD.'} + ]; + next(); +}, response('integral_time')); + + rqf.addField({ name: 'filter', field: false, @@ -191,8 +201,8 @@ rqf.addField({ }).addValue({ name: 'city', table: 'municipio', - tableField: 'nome', - resultField: 'city_name', + tableField: ['nome', 'id'], + resultField: ['city_name', 'city_id'], where: { relation: '=', type: 'integer', @@ -207,8 +217,8 @@ rqf.addField({ }).addValue({ name: 'state', table: 'estado', - tableField: 'nome', - resultField: 'state_name', + tableField: ['nome', 'id'], + resultField: ['state_name', 'state_id'], where: { relation: '=', type: 'integer', @@ -322,8 +332,8 @@ rqfCount.addField({ }, 'filter').addValue({ name: 'state', table: 'estado', - tableField: 'nome', - resultField: 'state_name', + tableField: ['nome', 'id'], + resultField: ['state_name', 'state_id'], where: { relation: '=', type: 'integer', @@ -338,8 +348,8 @@ rqfCount.addField({ }).addValue({ name: 'region', table: 'regiao', - tableField: 'nome', - resultField: 'region_name', + tableField: ['nome', 'id'], + resultField: ['region_name', 'region_id'], where: { relation: '=', type: 'integer', @@ -381,6 +391,16 @@ rqfCount.addField({ type: 'integer', field: 'localidade_area_rural' } +}).addValue({ + name: 'arrangement', + table: 'escola', + tableField: 'arranjo', + resultField: 'arrangement_id', + where: { + relation: '=', + type: 'integer', + field: 'arranjo' + } }).addValue({ name: 'adm_dependency', table: 'escola', @@ -404,13 +424,23 @@ rqfCount.addField({ }).addValue({ name: 'government_agreement', table: 'escola', - tableField: 'conveniada_pp', + tableField: 'dependencia_convenio_publico', resultField: 'government_agreement_id', where: { relation: '=', type: 'boolean', field: 'conveniada_pp' } +}).addValue({ + name: 'integral_time', + table: 'escola', + tableField: 'tempo_integral', + resultField: 'integral_time_id', + where: { + relation: '=', + type: 'boolean', + field: 'tempo_integral' + } }).addValue({ name: 'agreement', table: 'escola', @@ -541,10 +571,8 @@ schoolApp.get('/count', cache('15 day'), rqfCount.parse(), rqfCount.build(), (re .field('escola.ano_censo', 'year') .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)'); + .where('escola.situacao_funcionamento_pareada = 1 AND (escola.ensino_regular = 1 OR escola.ensino_eja=1 or escola.educacao_profissional=1)'); next(); -}, query, addMissing(rqfCount), id2str.transform(), response('school')); - -schoolApp.get('/count/download', passport.authenticate('bearer', { session: false }), rqfCount.parse(), rqfCount.build(), download('escola', 'mapping_escola')); +}, query, id2str.transform(), addMissing(rqfCount), response('school')); module.exports = schoolApp; diff --git a/src/libs/routes/teacher.js b/src/libs/routes/teacher.js index bef4eb33..59d6f8db 100644 --- a/src/libs/routes/teacher.js +++ b/src/libs/routes/teacher.js @@ -69,7 +69,7 @@ teacherApp.get('/source', (req, res, next) => { teacherApp.get('/adm_dependency_detailed', (req, res, next) => { req.result = []; - for(let i = 1; i <= 6; ++i) { + for(let i = 1; i <= 8; ++i) { req.result.push({ id: i, name: id2str.admDependencyPriv(i) @@ -91,12 +91,16 @@ teacherApp.get('/adm_dependency', (req, res, next) => { teacherApp.get('/education_level_mod', (req, res, next) => { req.result = []; - for(let i = 1; i <= 11; ++i) { + for(let i = 1; i <= 12; ++i) { req.result.push({ id: i, name: id2str.educationLevelMod(i) }); } + req.result.push({ + id: 99, + name: id2str.educationLevelMod(99) + }); next(); }, response('education_level_mod')); @@ -126,14 +130,13 @@ teacherApp.get('/location', (req, res, next) => { }, response('location')); teacherApp.get('/rural_location', (req, res, next) => { - req.result = [ - {id: 1, name: "Urbana"}, - {id: 2, name: "Rural"}, - {id: 3, name: "Rural - Ãrea de assentamento"}, - {id: 4, name: "Rural - Terra indÃgena"}, - {id: 5, name: "Rural - Ãrea remanescente de quilombos"}, - {id: 6, name: "Rural - Unidade de uso sustentável"} - ]; + req.result = []; + for (let i = 1; i <= 8; i++) { + req.result.push({ + id: i, + name: id2str.ruralLocation(i) + }); + }; next(); }, response('rural_location')); @@ -250,8 +253,8 @@ rqf.addField({ }).addValue({ name: 'region', table: 'regiao', - tableField: 'nome', - resultField: 'region_name', + tableField: ['nome', 'id'], + resultField: ['region_name', 'region_id'], where: { relation: '=', type: 'integer', @@ -265,8 +268,8 @@ rqf.addField({ }).addValue({ name: 'state', table: 'estado', - tableField: 'nome', - resultField: 'state_name', + tableField: ['nome', 'id'], + resultField: ['state_name', 'state_id'], where: { relation: '=', type: 'integer', @@ -407,12 +410,15 @@ teacherApp.get('/', rqf.parse(), (req, res, next) => { .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 = 1 OR docente.tipo_docente = 5) AND (turma.tipo_turma_id <= 3)'); - - if("education_level_mod" in req.dims) { - req.hadEducationLevelMod = true; - req.sql.where('docente.etapas_mod_ensino_segmento_id < 11'); - } + .where('(docente.tipo_docente = 1 OR docente.tipo_docente = 5) AND \ + ((docente.tipo_turma_id >= 0 AND docente.tipo_turma_id <= 3 AND docente.tipo_turma_atendimento_id is NULL) \ + OR ((docente.tipo_turma_atendimento_id = 1 OR docente.tipo_turma_atendimento_id = 2) AND docente.tipo_turma_id is NULL)) \ + AND (docente.ano_censo <> 2009 or docente.escola_estado_id <> 42)'); // não devemos trazer SC em 2009. + + // if("education_level_mod" in req.dims) { + // req.hadEducationLevelMod = true; + // req.sql.where('docente.etapas_mod_ensino_segmento_id < 11'); + // } next(); }, rqf.build(), query, addMissing(rqf), id2str.transform(), response('teacher')); -- GitLab