Skip to content
Snippets Groups Projects
Commit 1c8c1eb6 authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Add gender and ethnic_group to enrollment params

* Create routes /enrollment/gender and /enrollment/ethnic_group
* Add gender and ethnic_group to enrollment params in RQF
parent 37cedea0
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!34Db simcaq dev2
Pipeline #
......@@ -75,7 +75,7 @@ gulp.task('pre-test', () => {
gulp.task('test', ['pre-test'], () => {
process.chdir('build');
gulp.src(['test/**/*.js'], {read: false})
.pipe(mocha({timeout: 15000}))
.pipe(mocha({timeout: 30000}))
.pipe(istanbul.writeReports())
.pipe(istanbul.enforceThresholds({
thresholds: {
......@@ -84,7 +84,7 @@ gulp.task('test', ['pre-test'], () => {
branches: 70,
lines: 80,
functions: 80
}
}
}
}))
.on('error', () => {
......@@ -115,4 +115,4 @@ gulp.task('run', () => {
});
});
gulp.task('default', ['run']);
\ No newline at end of file
gulp.task('default', ['run']);
......@@ -35,9 +35,9 @@ enrollmentApp.get('/location', (req, res, next) => {
// Returns all educational levels avaible
enrollmentApp.get('/education_level', (req, res, next) => {
req.sql.from('etapa_ensino')
.field('id', 'id')
.field('desc_etapa', 'name');
req.sql.from('serie_ano')
.field('id')
.field('nome', 'name');
next();
}, query, response('education_level'));
......@@ -49,6 +49,28 @@ enrollmentApp.get('/adm_dependency', (req, res, next) => {
next();
}, query, response('adm_dependency'));
// Return genders
enrollmentApp.get('/gender', (req, res, next) => {
req.result = [
{id: 1, name: 'Masculino'},
{id: 2, name: 'Feminino'}
];
next();
}, response('gender'));
// Return ethnic group
enrollmentApp.get('/ethnic_group', (req, res, next) => {
req.result = [
{id: 0, name: 'Não declarada'},
{id: 1, name: 'Branca'},
{id: 2, name: 'Preta'},
{id: 3, name: 'Parda'},
{id: 4, name: 'Amarela'},
{id: 5, name: 'Indígena'}
];
next();
}, response('ethnic_group'));
rqf.addField({
name: 'filter',
field: false,
......@@ -74,9 +96,9 @@ rqf.addField({
}
}).addValue({
name: 'education_level',
table: 'etapa_ensino',
tableField: 'desc_etapa',
resultField: 'education_level',
table: 'serie_ano',
tableField: 'nome',
resultField: 'education_level_name',
where: {
relation: '=',
type: 'integer',
......@@ -84,7 +106,7 @@ rqf.addField({
},
join: {
primary: 'id',
foreign: 'etapa_ensino_id',
foreign: 'serie_ano_id',
foreignTable: 'matricula'
}
}).addValue({
......@@ -99,7 +121,7 @@ rqf.addField({
},
join: {
primary: 'id',
foreign: 'cod_regiao',
foreign: 'regiao_id',
foreignTable: 'matricula'
}
}).addValue({
......@@ -135,7 +157,7 @@ rqf.addField({
}).addValue({
name: 'school',
table: 'escola',
tableField: 'cod_entidade',
tableField: 'nome_escola',
resultField: 'school_name',
where: {
relation: '=',
......@@ -182,6 +204,26 @@ rqf.addField({
type: 'integer',
field: 'ano_censo'
}
}).addValue({
name: 'gender',
table: 'matricula',
tableField: 'sexo',
resultField: 'gender_id',
where: {
relation: '=',
type: 'integer',
field: 'sexo'
}
}).addValue({
name: 'ethnic_group',
table: 'matricula',
tableField: 'cor_raca',
resultField: 'ethnic_group_id',
where: {
relation: '=',
type: 'integer',
field: 'ethnic_group_id'
}
});
enrollmentApp.get('/', rqf.parse(), rqf.build(), (req, res, next) => {
......
......@@ -155,7 +155,7 @@ describe('request enrollments', () => {
it('should list enrollments with valid dimensions and filters', (done) => {
chai.request(server)
.get('/api/v1/enrollment?dims=region,state,education_level,school&filter=min_year:2013,max_year:2014,city:4106902')
.get('/api/v1/enrollment?dims=region,state,education_level,school&filter=min_year:2015,max_year:2015,city:4106902')
.end((err, res) => {
res.should.have.status(200);
res.should.be.json;
......@@ -163,8 +163,8 @@ describe('request enrollments', () => {
res.body.result.should.be.a('array');
res.body.result[0].should.have.property('region_name');
res.body.result[0].should.have.property('state_name');
//res.body.result[0].should.have.property('school_name');
res.body.result[0].should.have.property('education_level');
res.body.result[0].should.have.property('school_name');
res.body.result[0].should.have.property('education_level_name');
res.body.result[0].should.have.property('total');
res.body.result[0].should.have.property('year');
done();
......
......@@ -77,7 +77,7 @@ describe('Query middleware', () => {
it('should return 404 with an empty query result', (done) => {
let req = {
sql: squel.select().field('*').from('regiao').where('pk_regiao_id>6')
sql: squel.select().field('*').from('regiao').where('id>6')
};
let res = {};
query(req, {}, (error)=>{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment