diff --git a/src/libs/routes/school.js b/src/libs/routes/school.js index e08eca586cd4650fa07bcb6b555fb506c9b23dee..6f13b95bccd298fc2a93c1965970e7b27296afdb 100644 --- a/src/libs/routes/school.js +++ b/src/libs/routes/school.js @@ -41,18 +41,6 @@ schoolApp.get('/location', (req, res, next) => { next(); }, response('location')); -schoolApp.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"} - ]; - next(); -}, response('rural_location')); - schoolApp.get('/adm_dependency', (req, res, next) => { req.sql.from('dependencia_adm') .field('id') @@ -86,160 +74,6 @@ schoolApp.get('/agreement', (req, res, next) => { next(); }, response('agreement')); -schoolApp.get('/building_school', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('building_school')); - -schoolApp.get('/informatics_lab', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('informatics_lab')); - - -schoolApp.get('/science_lab', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('/science_lab')); - -schoolApp.get('/directors_room', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('directors_room')); - -schoolApp.get('/teacher_room', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('teacher_room')); - -schoolApp.get('/cook_room', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('cook_room')); - -schoolApp.get('/playground', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('playground')); - -schoolApp.get('/indor_sports_court', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('indor_sports_court')); - -schoolApp.get('/nusery', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('nusery')); - -schoolApp.get('/special_attendence_room', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('special_attendence_room')); - -schoolApp.get('/toilet_inside_building', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('toilet_inside_building')); - -schoolApp.get('/denpendency_pne', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('denpendency_pne')); - -schoolApp.get('/restroom_pne', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('restroom_pne')); - -schoolApp.get('/broadband', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('broadband')); - -schoolApp.get('/energy', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('energy')); - -schoolApp.get('/water', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('water')); - -schoolApp.get('/wastepipe', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('wastepipe')); - schoolApp.get('/education_day_care_child', (req, res, next) => { req.result = [ {id: null, name: 'Não Declarado'}, @@ -303,33 +137,6 @@ schoolApp.get('/education_eja', (req, res, next) => { next(); }, response('education_eja')); -schoolApp.get('/library', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('library')); - -schoolApp.get('/reading_room', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('reading_room')); - -schoolApp.get('/library_reading_room', (req, res, next) => { - req.result = [ - {id: null, name: 'Não Declarado'}, - {id: 0, name: 'Não'}, - {id: 1, name: 'Sim'} - ]; - next(); -}, response('library_reading_room')); - rqf.addField({ name: 'filter', field: false, @@ -479,6 +286,16 @@ rqfCount.addField({ field: 'ano_censo', table: 'escola' } +}).addValue({ + name: 'location', + table: 'escola', + tableField: 'cod_localizacao', + resultField: 'location_id', + where: { + relation: '=', + type: 'integer', + field: 'cod_localizacao' + } }).addValue({ name: 'adm_dependency', table: 'escola', @@ -499,36 +316,6 @@ rqfCount.addField({ type: 'integer', field: 'dependencia_adm_priv' } -}).addValue({ - name: 'location', - table: 'escola', - tableField: 'cod_localizacao', - resultField: 'location_id', - where: { - relation: '=', - type: 'integer', - field: 'cod_localizacao' - } -// }).addValue({ -// name: 'rural_location', -// table: 'escola', -// tableField: 'localidade_area_rural', -// resultField: 'rural_location_id', -// where: { -// relation: '=', -// type: 'integer', -// field: 'localidade_area_rural' -// } -// }).addValue({ -// name: 'cook_room', -// table: 'escola', -// tableField: 'cozinha', -// resultField: 'cook_room_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'cozinha' -// } }).addValue({ name: 'government_agreement', table: 'escola', @@ -539,277 +326,86 @@ rqfCount.addField({ type: 'boolean', field: 'conveniada_pp' } -// }).addValue({ -// name: 'informatics_lab', -// table: 'escola', -// tableField: 'lab_informatica', -// resultField: 'informatics_lab_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'lab_informatica' -// } -// }).addValue({ -// name: 'science_lab', -// table: 'escola', -// tableField: 'lab_ciencias', -// resultField: 'science_lab_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'lab_ciencias' -// } -// }).addValue({ -// name: 'special_attendence_room', -// table: 'escola', -// tableField: 'sala_atendimento_especial', -// resultField: 'special_attendence_room_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'sala_atendimento_especial' -// } -// }).addValue({ -// name: 'indor_sports_court', -// table: 'escola', -// tableField: 'quadra_esportes_coberta', -// resultField: 'indor_sports_court_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'quadra_esportes_coberta' -// } }).addValue({ - name: 'education_eja', + name: 'agreement', table: 'escola', - tableField: 'ensino_eja', - resultField: 'education_eja_id', + tableField: 'tipo_convenio_pp', + resultField: 'agreement_id', where: { relation: '=', - type: 'boolean', - field: 'ensino_eja' + type: 'integer', + field: 'tipo_convenio_pp' } }).addValue({ - name: 'education_professional', + name: 'education_day_care_child', table: 'escola', - tableField: 'educacao_profissional', - resultField: 'education_professional_id', + tableField: 'reg_infantil_creche', + resultField: 'education_day_care_child_id', where: { relation: '=', type: 'boolean', - field: 'educacao_profissional' + field: 'reg_infantil_creche' } }).addValue({ - name: 'education_middle_school', + name: 'education_preschool_child', table: 'escola', - tableField: 'reg_medio_medio', - resultField: 'education_middle_school_id', + tableField: 'reg_infantil_preescola', + resultField: 'education_preschool_child_id', where: { relation: '=', type: 'boolean', - field: 'reg_medio_medio' + field: 'reg_infantil_preescola' } }).addValue({ - name: 'education_end_elementary_school', + name: 'education_begin_elementary_school', table: 'escola', - tableField: 'reg_fund_af', - resultField: 'education_end_elementary_school_id', + tableField: 'reg_fund_ai', + resultField: 'education_begin_elementary_school_id', where: { relation: '=', type: 'boolean', - field: 'reg_fund_af' + field: 'reg_fund_ai' } }).addValue({ - name: 'education_begin_elementary_school', + name: 'education_end_elementary_school', table: 'escola', - tableField: 'reg_fund_ai', - resultField: 'education_begin_elementary_school_id', + tableField: 'reg_fund_af', + resultField: 'education_end_elementary_school_id', where: { relation: '=', type: 'boolean', - field: 'reg_fund_ai' + field: 'reg_fund_af' } }).addValue({ - name: 'education_preschool_child', + name: 'education_middle_school', table: 'escola', - tableField: 'reg_infantil_preescola', - resultField: 'education_preschool_child_id', + tableField: 'reg_medio_medio', + resultField: 'education_middle_school_id', where: { relation: '=', type: 'boolean', - field: 'reg_infantil_preescola' + field: 'reg_medio_medio' } }).addValue({ - name: 'education_day_care_child', + name: 'education_professional', table: 'escola', - tableField: 'reg_infantil_creche', - resultField: 'education_day_care_child_id', + tableField: 'educacao_profissional', + resultField: 'education_professional_id', where: { relation: '=', type: 'boolean', - field: 'reg_infantil_creche' + field: 'educacao_profissional' } -// }).addValue({ -// name: 'directors_room', -// table: 'escola', -// tableField: 'sala_diretoria', -// resultField: 'directors_room_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'sala_diretoria' -// } -// }).addValue({ -// name: 'teacher_room', -// table: 'escola', -// tableField: 'sala_professor', -// resultField: 'teacher_room_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'sala_professor' -// } -// }).addValue({ -// name: 'playground', -// table: 'escola', -// tableField: 'parque_infantil', -// resultField: 'playground_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'parque_infantil' -// } -// }).addValue({ -// name: 'nusery', -// table: 'escola', -// tableField: 'bercario', -// resultField: 'nusery_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'bercario' -// } -// }).addValue({ -// name: 'toilet_inside_building', -// table: 'escola', -// tableField: 'sanitario_dentro_predio', -// resultField: 'toilet_inside_building_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'sanitario_dentro_predio' -// } -// }).addValue({ -// name: 'wastepipe', -// table: 'escola', -// tableField: 'esgoto_sanitario', -// resultField: 'wastepipe_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'esgoto_sanitario' -// } -// }).addValue({ -// name: 'water', -// table: 'escola', -// tableField: 'fornecimento_agua', -// resultField: 'water_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'fornecimento_agua ' -// } -// }).addValue({ -// name: 'energy', -// table: 'escola', -// tableField: 'fornecimento_energia', -// resultField: 'energy_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'fornecimento_energia ' -// } -// }).addValue({ -// name: 'broadband', -// table: 'escola', -// tableField: 'internet_banda_larga', -// resultField: 'broadband_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'internet_banda_larga ' -// } -// }).addValue({ -// name: 'restroom_pne', -// table: 'escola', -// tableField: 'sanitario_pne', -// resultField: 'restroom_pne_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'sanitario_pne ' -// } -// }).addValue({ -// name: 'denpendency_pne', -// table: 'escola', -// tableField: 'dependencias_pne', -// resultField: 'denpendency_pne_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'dependencias_pne ' -// } }).addValue({ - name: 'agreement', + name: 'education_eja', table: 'escola', - tableField: 'tipo_convenio_pp', - resultField: 'agreement_id', + tableField: 'ensino_eja', + resultField: 'education_eja_id', where: { relation: '=', - type: 'integer', - field: 'tipo_convenio_pp' + type: 'boolean', + field: 'ensino_eja' } -// }).addValue({ -// name: 'building_school', -// table: 'escola', -// tableField: 'local_func_predio_escolar', -// resultField: 'building_school_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'local_func_predio_escolar' -// } -// }).addValue({ -// name: 'library', -// table: 'escola', -// tableField: 'biblioteca', -// resultField: 'library_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'biblioteca' -// } -// }).addValue({ -// name: 'reading_room', -// table: 'escola', -// tableField: 'sala_leitura', -// resultField: 'reading_room_id', -// where: { -// relation: '=', -// type: 'boolean', -// field: 'sala_leitura' -// } -// }).addValue({ -// name: 'library_reading_room', -// table: 'escola', -// tableField: 'biblioteca_sala_leitura', -// resultField: 'library_reading_room_id', -// where: { -// relation: '=', -// type: 'boolean', -// condition: 'or', -// field: 'biblioteca_sala_leitura' -// } }).addValue({ name: 'min_year', table: 'escola', @@ -831,20 +427,6 @@ rqfCount.addField({ field: 'ano_censo' } }); - -// .addValue({ //Using multiple_where -// name: 'library_reading_room', -// table: 'escola', -// tableField: ['biblioteca', 'sala_leitura', 'biblioteca_sala_leitura'], -// resultField: 'library_or_reading_room', -// where: { -// relation: '=', -// type: 'boolean', -// condition: 'or', -// field: ['biblioteca', 'sala_leitura', 'biblioteca_sala_leitura'] -// } - -// SELECT COUNT(escola.id) AS "total", 'Brasil' AS "name", escola.ano_censo AS "year" FROM escola WHERE (escola.biblioteca = ? OR escola.sala_leitura = ? OR escola.biblioteca_sala_leitura) AND (escola.situacao_de_funcionamento = 1 AND escola.ensino_regular = 1) GROUP BY escola.ano_censo ORDER BY escola.ano_censo ASC schoolApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => { if(typeof req.filter === 'undefined' || Object.keys(req.filter).length === 0) { res.status(400);