Commit f492348f authored by Vytor Calixto's avatar Vytor Calixto 👾

Merge branch 'release_v1.8.0'

Merges !162
parents b05a5b9d 196e9da7
Pipeline #18465 failed with stage
in 1 minute and 46 seconds
......@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## 1.8.0 - 2018-11-13
### Added
- Add financial route
- Add employees route
### Changed
- Fix school route
- Fix transport route
- Fix return where integral time is null
- Classroom count route returns school year results for education level 1
## 1.7.0 - 2018-09-20
### Changed
- Fix return string in contract type id 1
......
module.exports = function integralTime(id) {
if (id == null)
return 'Não se aplica (semi presencial e EaD)';
else if (id == false)
return 'Não';
else if (id == true)
return 'Sim';
};
......@@ -7,6 +7,6 @@ module.exports = function period(id) {
case 3:
return 'Noturno';
default:
return 'Indefinido';
return 'Não se aplica (semi presencial e EaD)';
}
};
......@@ -30,6 +30,8 @@ const useTransport = require(`${libs}/convert/booleanVariable`);
const useTransportPublic = require(`${libs}/convert/booleanVariable`);
const transportationManager = require(`${libs}/convert/transportationManager`);
const specialClass = require(`${libs}/convert/booleanVariable`);
const integralTime = require(`${libs}/convert/integralTime`);
const educationLevelSchoolYear = require(`${libs}/convert/educationLevelSchoolYear`);
const ids = {
gender_id: gender,
......@@ -46,7 +48,7 @@ const ids = {
location_detailed_id: ruralLocation,
ethnic_group_id: ethnicGroup,
agreement_id: agreement,
integral_time_id: booleanVariable,
integral_time_id: integralTime,
government_agreement_id: booleanVariable,
education_day_care_child_id: booleanVariable,
education_preschool_child_id: booleanVariable,
......@@ -71,7 +73,8 @@ const ids = {
use_transport_id: useTransport,
use_transport_public_id: useTransportPublic,
transportation_manager_id: transportationManager,
special_class_id: specialClass
special_class_id: specialClass,
education_level_school_year_id: educationLevelSchoolYear,
};
function transform(removeId=false) {
......@@ -141,5 +144,6 @@ module.exports = {
extremesHouseholdIncome,
useTransport,
transportationManager,
specialClass
specialClass,
integralTime
};
......@@ -80,6 +80,9 @@ const classCount = require(`${libs}/routes/classCount`);
const portalMecInep = require(`${libs}/routes/portalMecInep`);
const employees = require(`${libs}/routes/employees`);
const financial = require(`${libs}/routes/financial`);
api.get('/', (req, res) => {
res.json({ msg: 'SimCAQ API is running' });
......@@ -123,5 +126,8 @@ api.use('/auxiliar', auxiliar);
api.use('/verify_teacher', verifyTeacher);
api.use('/class_count', classCount);
api.use('/portal_mec_inep', portalMecInep);
api.use('/employees', employees);
api.use('/financial', financial);
module.exports = api;
This diff is collapsed.
This diff is collapsed.
const express = require('express');
const financialApp = express.Router();
const libs = `${process.cwd()}/libs`;
const log = require(`${libs}/log`)(module);
const squel = require('squel');
const query = require(`${libs}/middlewares/query`).query;
const response = require(`${libs}/middlewares/response`);
const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
const id2str = require(`${libs}/middlewares/id2str`);
const addMissing = require(`${libs}/middlewares/addMissing`);
const config = require(`${libs}/config`);
const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
let rqf = new ReqQueryFields();
financialApp.get('/year_range', (req, res, next) => {
req.sql.from('indicadores_financeiros')
.field('MIN(indicadores_financeiros.ano_censo)', 'start_year')
.field('MAX(indicadores_financeiros.ano_censo)', 'end_year');
next();
}, query, response('range'));
financialApp.get('/years', (req, res, next) => {
req.sql.from('indicadores_financeiros')
.field('DISTINCT indicadores_financeiros.ano_censo', 'year');
next();
}, query, response('years'));
financialApp.get('/sphere_adm', (req, res, next) => {
req.result = [
{id: 1, name: "1"},
{id: 2, name: "2"}
]
next();
}, response('sphere_adm'));
financialApp.get('/financial_data', (req, res, next) => {
req.sql.from('indicadores_financeiros')
.field('DISTINCT indicadores_financeiros.dados_financeiros', 'financial_data');
next();
}, query, response('financial_data'));
rqf.addField({
name: 'filter',
field: false,
where: true
}).addField({
name: 'dims',
field: true,
where: false
}).addValue({
name: 'state',
table: 'estado',
tableField: ['sigla', 'id'],
resultField: ['sigla_uf', 'cod_uf'],
where: {
relation: '=',
type: 'integer',
field: 'estado_id',
table: 'indicadores_financeiros'
},
join: {
primary: 'id',
foreign: 'estado_id',
foreignTable: 'indicadores_financeiros'
}
}).addValue({
name: 'min_year',
table: 'indicadores_financeiros',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '>=',
type: 'integer',
table: 'indicadores_financeiros',
field: 'ano_censo'
}
}).addValue({
name: 'max_year',
table: 'indicadores_financeiros',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '<=',
type: 'integer',
table: 'indicadores_financeiros',
field: 'ano_censo'
}
}).addValue({
name: 'sphere_adm',
table: 'indicadores_financeiros',
tableField: 'esfera_adm',
resultField: 'sphere_adm_id',
where: {
relation: '=',
type: 'integer',
field: 'esfera_adm'
}
}).addValue({
name: 'city',
table: 'indicadores_financeiros',
tableField: 'municipio_id',
resultField: 'city_id',
where: {
relation: '=',
type: 'integer',
field: 'municipio_id'
}
}).addValue({
name: 'financial_data',
table: 'indicadores_financeiros',
tableField: 'dados_financeiros',
resultField: 'financial_data_id',
where: {
relation: '=',
type: 'integer',
field: 'dados_financeiros'
}
});
financialApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.from('indicadores_financeiros')
.field('indicadores_financeiros.estado_id', 'state_id')
.field('indicadores_financeiros.ano_censo', 'year')
.field('estado.sigla', 'state_abbreviation')
.field('indicadores_financeiros.valor', 'valor')
.field('indicadores_financeiros.esfera_adm', 'sphere_adm_id')
.field('indicadores_financeiros.dados_financeiros', 'financial_data_id')
.join('estado', null, 'indicadores_financeiros.estado_id=estado.id')
.group('indicadores_financeiros.ano_censo')
.group('indicadores_financeiros.estado_id')
.group('estado.sigla')
.group('indicadores_financeiros.valor')
.group('indicadores_financeiros.dados_financeiros')
.group('indicadores_financeiros.esfera_adm')
next();
}, query, addMissing(rqf), id2str.transform(), response('financial'));
module.exports = financialApp;
......@@ -60,6 +60,18 @@ schoolApp.get('/location', cache('15 day'), (req, res, next) => {
next();
}, response('location'));
schoolApp.get('/rural_location', cache('15 day'), (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.result = [];
for(let i = 1; i <= 4; ++i) {
......@@ -359,6 +371,16 @@ rqfCount.addField({
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: 'adm_dependency',
table: 'escola',
......@@ -402,52 +424,52 @@ rqfCount.addField({
}).addValue({
name: 'education_day_care_child',
table: 'escola',
tableField: 'reg_infantil_creche',
tableField: 'reg_infantil_creche_t1',
resultField: 'education_day_care_child_id',
where: {
relation: '=',
type: 'boolean',
field: 'reg_infantil_creche'
field: 'reg_infantil_creche_t1'
}
}).addValue({
name: 'education_preschool_child',
table: 'escola',
tableField: 'reg_infantil_preescola',
tableField: 'reg_infantil_preescola_t1',
resultField: 'education_preschool_child_id',
where: {
relation: '=',
type: 'boolean',
field: 'reg_infantil_preescola'
field: 'reg_infantil_preescola_t1'
}
}).addValue({
name: 'education_begin_elementary_school',
table: 'escola',
tableField: 'reg_fund_ai',
tableField: 'reg_fund_ai_t1',
resultField: 'education_begin_elementary_school_id',
where: {
relation: '=',
type: 'boolean',
field: 'reg_fund_ai'
field: 'reg_fund_ai_t1'
}
}).addValue({
name: 'education_end_elementary_school',
table: 'escola',
tableField: 'reg_fund_af',
tableField: 'reg_fund_af_t1',
resultField: 'education_end_elementary_school_id',
where: {
relation: '=',
type: 'boolean',
field: 'reg_fund_af'
field: 'reg_fund_af_t1'
}
}).addValue({
name: 'education_middle_school',
table: 'escola',
tableField: 'reg_medio_medio',
tableField: 'reg_medio_medio_t1',
resultField: 'education_middle_school_id',
where: {
relation: '=',
type: 'boolean',
field: 'reg_medio_medio'
field: 'reg_medio_medio_t1'
}
}).addValue({
name: 'education_professional',
......
......@@ -83,17 +83,21 @@ transportApp.get('/rural_location', (req, res, next) => {
next();
}, response('rural_location'));
transportApp.get('/education_level_basic', (req, res, next) => {
transportApp.get('/education_level_mod', (req, res, next) => {
req.result = [
{id: null, name: 'Não classificada'},
{id: 1, name: 'Creche'},
{id: 2, name: 'Pré-Escola'},
{id: 4, name: 'Ensino Fundamental - anos iniciais'},
{id: 5, name: 'Ensino Fundamental - anos finais'},
{id: 6, name: 'Ensino Médio'}
{id: 6, name: 'Ensino Médio'},
{id: 7, name: 'Turmas multiseriadas e multietapas'},
{id: 8, name: 'EJA - Ensino Fundamental'},
{id: 9, name: 'EJA - Ensino Médio'},
{id: 10, name: 'Educação Profissional'}
];
next();
}, response('education_level_basic'));
}, response('education_level_mod'));
transportApp.get('/service_type', (req, res, next) => {
req.result = [
......@@ -244,10 +248,10 @@ rqf.addField({
field: 'responsavel_transp'
}
}).addValue({
name: 'education_level_basic',
name: 'education_level_mod',
table: 'matricula',
tableField: 'etapas_mod_ensino_segmento_id',
resultField: 'education_level_basic_id',
resultField: 'education_level_mod_id',
where: {
relation: '=',
type: 'integer',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment