Skip to content
Snippets Groups Projects
Commit cca715af authored by Guiusepe's avatar Guiusepe
Browse files

Merge branch 'homologa' into 'new_updates'

Homologa

See merge request !335
parents f42364e3 59f1ff86
Branches
Tags
4 merge requests!342Hotfix filters,!341Hotfix filters,!335Homologa,!309Merge new updates into master
......@@ -19,6 +19,8 @@ along with simcaq-node. If not, see <https://www.gnu.org/licenses/>.
*/
module.exports = function cineDetailed(id) {
switch (id) {
case 11:
return 'Programas Básicos';
case 111:
return 'Ciência da educação';
case 112:
......
......@@ -118,6 +118,8 @@ const educationalBudget = require(`${libs}/routes/educationalBudget`);
const schoolLocation = require(`${libs}/routes/schoolLocation`);
const studentsAee = require(`${libs}/routes/studentsAee`);
const mesoregion = require(`${libs}/routes/mesoregion`);
const microregion = require(`${libs}/routes/microregion`);
......@@ -182,6 +184,7 @@ api.use('/university', university);
api.use('/university_teacher', universityTeacher);
api.use('/course_count', courseCount);
api.use('/school_location', schoolLocation);
api.use('/students_aee', studentsAee);
api.use('/mesoregion', mesoregion);
api.use('/microregion', microregion);
api.use('/location', location);
......
......@@ -69,6 +69,22 @@ rqf.addField({
foreign: 'estado_id',
foreignTable: 'municipio'
}
}).addValue({
name: 'state_not',
table: 'estado',
tableField: ['nome', 'id'],
resultField: ['state_name', 'state_id'],
where: {
relation: '<>',
type: 'integer',
field: 'estado_id',
table: 'municipio'
},
join: {
primary: 'id',
foreign: 'estado_id',
foreignTable: 'municipio'
}
}).addField({
name: 'search',
field: false,
......@@ -100,7 +116,23 @@ rqf.addField({
type: 'integer',
field: 'microrregiao_id'
}
});
}).addValueToField({
name: 'region',
table: 'estado',
tableField: 'regiao_id',
resultField: 'region_id',
where: {
relation: '=',
type: 'integer',
field: 'regiao_id',
table: 'estado'
},
join: {
primary: 'id',
foreign: 'estado_id',
foreignTable: 'municipio'
}
}, 'filter');
// Return all cities
cityApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
......
......@@ -36,6 +36,16 @@ rqf.addField({
field: 'id',
table: '@'
}
}).addValue({
name: 'id_not',
table: '@',
tableField: 'id',
where: {
relation: '<>',
type: 'integer',
field: 'id',
table: '@'
}
}).addField({
name: 'search',
field: false,
......
......@@ -53,6 +53,15 @@ rqf.addField({
type: 'integer',
field: 'id'
}
}).addValue({
name: 'id_not',
table: 'estado',
tableField: 'id',
where: {
relation: '<>',
type: 'integer',
field: 'id'
}
}).addValue({
name: 'region',
table: 'regiao',
......
const express = require('express');
const studentsAeeApp = 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 id2str = require(`${libs}/middlewares/id2str`);
const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
const request = require(`request`);
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;
let rqf = new ReqQueryFields();
let rqfCount = new ReqQueryFields();
// cubApp.get('/year_range', (req, res, next) => {
// req.sql.from('cub')
// .field('MIN(cub.ano_censo)', 'start_year')
// .field('MAX(cub.ano_censo)', 'end_year');
// next();
// }, query, response('range'));
// cubApp.get('/years', (req, res, next) => {
// req.sql.from('cub')
// .field('DISTINCT cub.ano_censo', 'year');
// next();
// }, query, response('years'));
// cubApp.get('/months', (req, res, next) => {
// req.sql.from('cub')
// .field('DISTINCT cub.mes_censo', 'month');
// next();
// }, query, response('months'));
// cubApp.get('/years_months', (req, res, next) => {
// req.sql.from('cub')
// .field('DISTINCT cub.ano_censo AS "year", cub.mes_censo AS "month"');
// next();
// }, query, response('years_months'));
// cubApp.get('/price_type', (req, res, next) => {
// req.sql.from('cub')
// .field('DISTINCT cub.tipo_preco', 'price_type');
// next();
// }, query, response('price_type'));
rqf.addField({
name: 'filter',
field: false,
where: true
}).addField({
name: 'dims',
field: true,
where: false
}).addValueToField({
name: 'state', // working
table: 'estado',
tableField: ['sigla', 'id'],
resultField: ['sigla_uf', 'cod_uf'],
where: {
relation: '=',
type: 'integer',
field: 'estado_id',
table: 'numero_estudantes_aee'
},
join: {
primary: 'id',
foreign: 'estado_id',
foreignTable: 'numero_estudantes_aee'
}
}, 'filter').addValueToField({
name: 'city', // working
table: 'municipio',
tableField: ['nome', 'id'],
resultField: ['city_name', 'city_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'municipio_id',
foreignTable: 'numero_estudantes_aee'
}
}, 'filter').addValue({
name: 'region', // working
table: 'regiao',
tableField: ['nome', 'id'],
resultField: ['region_name', 'region_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'regiao_id',
foreignTable: 'numero_estudantes_aee'
}
}).addValueToField({
name: 'school', // working
table: 'escola',
tableField: ['nome_escola', 'id'],
resultField: ['school_name', 'school_id'],
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: ['id', 'ano_censo'],
foreign: ['escola_id', 'ano_censo'],
foreignTable: 'numero_estudantes_aee'
}
}, 'filter').addValueToField({
name: 'locale_id', // working
table: 'numero_estudantes_aee',
tableField: 'localidade_area_rural',
resultField: 'locale_id',
where: {
relation: '=',
type: 'integer',
field: 'localidade_area_rural'
}
}, 'filter').addValue({
name: 'ethnic_group', // working
table: 'numero_estudantes_aee',
tableField: 'cor_raca_id',
resultField: 'ethnic_group_id',
where: {
relation: '=',
type: 'integer',
field: 'cor_raca_id'
}
}).addValue({
name: 'adm_dependency', // working
table: 'numero_estudantes_aee',
tableField: 'dependencia_adm_priv',
resultField: 'adm_dependency_id',
where: {
relation: '=',
type: 'integer',
field: 'dependencia_adm_priv'
}
}).addValue({
name:'age_range_all', // working
table: 'numero_estudantes_aee',
tableField: 'faixa_etaria_31_03',
resultField: 'age_range_all_id',
where: {
relation: '=',
type: 'integer',
field: 'faixa_etaria_31_03'
}
}).addValue({
name: 'gender', // working
table: 'numero_estudantes_aee',
tableField: 'sexo',
resultField: 'gender_id',
where: {
relation: '=',
type: 'integer',
field: 'sexo'
}
}).addValue({
name: 'activity_days', // working
table: 'numero_estudantes_aee',
tableField: 'dias_atividade',
resultField: 'activity_days_id',
where: {
relation: '=',
type: 'integer',
field: 'dias_atividade'
}
}).addField({
name: 'special_service', // working
table: 'numero_estudantes_aee',
tableField: 'disc_atendimento_especiais',
resultField: 'special_service_id',
where: {
relation: '=',
type: 'integer',
field: 'disc_atendimento_especiais'
}
});
studentsAeeApp.get('/', rqf.parse(), (req, res, next) => {
req.sql.from('numero_estudantes_aee')
.field('numero_estudantes_aee.ano_censo')
.field('COUNT(distinct numero_estudantes_aee.id_aluno)', 'total')
.group('numero_estudantes_aee.ano_censo')
.order('numero_estudantes_aee.ano_censo')
next();
}, rqf.build(), (req, res, next) => {
console.log(req.sql.toString());
next();
}, query, id2str.transform(), response('studentsAee'));
module.exports = studentsAeeApp;
......@@ -466,8 +466,8 @@ rqf.addField({
}).addValue({
name:'ocde_specific',
table: '@',
tableField: ['par_cod_ocde_area_especifica', 'nome_ocde_area_especifica'],
resultField: ['ocde_specific_id', 'ocde_specific_name'],
tableField: ['par_cod_ocde_area_especifica'],
resultField: ['ocde_specific_id'],
where: {
relation: '=',
type: 'integer',
......@@ -476,8 +476,8 @@ rqf.addField({
}).addValue({
name:'ocde_geral',
table: '@',
tableField: ['par_cod_ocde_area_geral', 'nome_ocde_area_geral'],
resultField: ['ocde_geral_id', 'ocde_geral_name'],
tableField: ['par_cod_ocde_area_geral'],
resultField: ['ocde_geral_id'],
where: {
relation: '=',
type: 'integer',
......@@ -486,8 +486,8 @@ rqf.addField({
}).addValue({
name:'ocde_detailed',
table: '@',
tableField: ['par_cod_ocde_area_detalhada', 'nome_ocde_area_detalhada'],
resultField: ['ocde_detailed_id', 'ocde_detailed_name'],
tableField: ['par_cod_ocde_area_detalhada'],
resultField: ['ocde_detailed_id'],
where: {
relation: '=',
type: 'integer',
......@@ -732,8 +732,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => {
.field('curso_ens_superior.ano_censo', 'year')
.field('COUNT(localoferta_ens_superior.cod_local_oferta)', 'total')
.group('localoferta_ens_superior_matricula.ano_censo')
.where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1')
.where('localoferta_ens_superior_matricula.cod_nivel_academico = 1')
.order('localoferta_ens_superior_matricula.ano_censo')
.order('localoferta_ens_superior.cod_local_oferta');
} else {
......@@ -745,8 +743,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => {
.group('localoferta_ens_superior_matricula.ano_censo')
.group('localoferta_ens_superior_matricula.cod_ies')
.group('localoferta_ens_superior_matricula.nome_ies')
.where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1')
.where('localoferta_ens_superior_matricula.cod_nivel_academico = 1')
.order('localoferta_ens_superior_matricula.ano_censo')
.order('localoferta_ens_superior_matricula.cod_local_oferta');
}
......@@ -756,8 +752,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => {
.field('DISTINCT COUNT(*)', 'total')
.field("'Brasil'", 'name')
.field('localoferta_ens_superior_matricula.ano_censo', 'year')
.where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1')
.where('localoferta_ens_superior_matricula.cod_nivel_academico = 1')
.group('localoferta_ens_superior_matricula.ano_censo')
.order('localoferta_ens_superior_matricula.ano_censo')
} else if ("university" in req.dims || "universityLocalOffer" in req.dims) {
......@@ -765,8 +759,6 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => {
.field('COUNT(*)', 'total')
.field("'Brasil'", 'name')
.field('aluno_ens_superior.ano_censo', 'year')
.where('aluno_ens_superior.cod_aluno_situacao = 2 OR aluno_ens_superior.cod_aluno_situacao = 6 OR aluno_ens_superior.matriculado = 1')
.where('aluno_ens_superior.cod_nivel_academico = 1')
.group('aluno_ens_superior.cod_ies')
.group('aluno_ens_superior.ano_censo')
.order('aluno_ens_superior.cod_ies')
......@@ -776,13 +768,11 @@ universityEnrollmentApp.get('/', rqf.parse(), (req, res, next) => {
.field('COUNT(*)', 'total')
.field("'Brasil'", 'name')
.field('localoferta_ens_superior_matricula.ano_censo', 'year')
.where('localoferta_ens_superior_matricula.cod_aluno_situacao = 2 OR localoferta_ens_superior_matricula.cod_aluno_situacao = 6 OR localoferta_ens_superior_matricula.matriculado = 1')
.where('localoferta_ens_superior_matricula.cod_nivel_academico = 1')
.group('localoferta_ens_superior_matricula.ano_censo')
.order('localoferta_ens_superior_matricula.ano_censo')
}
next();
}, rqf.build(), query, id2str.transform(), addMissing(rqf), (req, res, next) => {
}, rqf.build(), query, (req, res, next) =>{ console.log(req.sql.toString()); next()}, id2str.transform(), addMissing(rqf), (req, res, next) => {
if ('course' in req.dims){
var total_course = req.result.reduce((total, cur) => {return total += cur.total}, 0)
for (var course of req.result){
......@@ -801,7 +791,6 @@ universityEnrollmentApp.get('/enter_situation', rqf.parse(), (req, res, next) =>
.field('COUNT(*)', 'total')
.field("'Brasil'", 'name')
.field('localoferta_ens_superior_matricula.ano_censo', 'year')
.where('localoferta_ens_superior_matricula.cod_nivel_academico=1')
.where('localoferta_ens_superior_matricula.cod_grau_academico=2 OR localoferta_ens_superior_matricula.cod_grau_academico=4')
.group('localoferta_ens_superior_matricula.ano_censo')
.order('localoferta_ens_superior_matricula.ano_censo')
......@@ -826,7 +815,6 @@ universityEnrollmentApp.get('/enrollment_situation', rqf.parse(), (req, res, nex
.field('SUM(CASE WHEN localoferta_ens_superior_matricula.cod_aluno_situacao=3 THEN 1 ELSE 0 END)', 'trancado')
.field('localoferta_ens_superior_matricula.ano_censo', 'year')
.field("'Brasil'", 'name')
.where('localoferta_ens_superior_matricula.cod_nivel_academico=1')
.where('localoferta_ens_superior_matricula.cod_grau_academico=2 OR localoferta_ens_superior_matricula.cod_grau_academico=4')
.group('localoferta_ens_superior_matricula.ano_censo')
.order('localoferta_ens_superior_matricula.ano_censo')
......
......@@ -126,13 +126,38 @@ rqf.addField({
foreign: 'cod_uf',
foreignTable: 'localoferta_ens_superior'
}
}).addValueToField({
name: 'university',
table: 'localoferta_ens_superior',
tableField: 'cod_ies',
resultField: 'university_id',
where: {
relation: '=',
type: 'integer',
field: 'cod_ies',
table: 'localoferta_ens_superior'
}
}, 'filter').addValue({
name: 'year',
table: 'localoferta_ens_superior',
tableField: 'ano_censo',
resultField: 'year',
where: {
relation: '=',
type: 'integer',
table: 'localoferta_ens_superior',
field: 'ano_censo'
}
});
universityLocalOfferApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
req.sql.from('localoferta_ens_superior')
.field('distinct localoferta_ens_superior.cod_ies', 'id')
.field('localoferta_ens_superior.cod_local_oferta', 'localoffer_id')
.field('localoferta_ens_superior.ano_censo', 'year')
.field('ies_ens_superior.nome_ies', 'name')
.field('localoferta_ens_superior.nome', 'localoffer_name')
.field('localoferta_ens_superior.cod_uf', 'state_id')
.field('localoferta_ens_superior.cod_municipio', 'city_id')
.field('localoferta_ens_superior.cod_regiao', 'region_id')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment