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

Change /class to use id2str middleware

cc: @fce15
parent 81986d88
No related branches found
No related tags found
2 merge requests!116Release v1.0.0,!44Feature multiple where
Pipeline #
......@@ -14,6 +14,8 @@ const response = require(`${libs}/middlewares/response`);
const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
const id2str = require(`${libs}/middlewares/id2str`);
let rqfCount = new ReqQueryFields();
// Complete range of the enrollments dataset.
// Returns a tuple of start and ending years of the complete enrollments dataset.
......@@ -141,78 +143,53 @@ rqfCount.addField({
}
}).addValue({
name:'adm_dependency',
table: 'dependencia_adm',
tableField: 'id',
resultField: 'adm_dependency_name',
table: 'turma',
tableField: 'dependencia_adm_id',
resultField: 'adm_dependency_id',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'dependencia_adm_id',
foreignTable: 'turma'
field: 'adm_dependency_id'
}
}).addValue({
name: 'location',
table: 'localizacao',
tableField: 'descricao',
resultField: 'location_name',
table: 'turma',
tableField: 'localizacao_id',
resultField: 'location_id',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'localizacao_id',
foreignTable: 'turma'
field: 'location_id'
}
}).addValue({
name:'education_level',
table: 'etapas_mod_ensino_segmento ',
tableField: 'id',
resultField: 'education_level_name',
table: 'turma',
tableField: 'etapas_mod_ensino_segmento_id',
resultField: 'education_level_id',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'etapas_mod_ensino_segmento_id',
foreignTable: 'turma'
field: 'etapas_mod_ensino_segmento_id'
}
}).addValue({
name: 'adm_dependency_detailed',
table: 'dependencia_adm',
tableField: 'nome',
resultField: 'adm_dependency_detailed_name',
table: 'turma',
tableField: 'dependencia_adm_priv',
resultField: 'adm_dependency_detailed_id',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'dependencia_adm_priv',
foreignTable: 'turma'
field: 'dependencia_adm_priv'
}
}).addValue({
name:'period',
table: 'turma_turno',
tableField: 'id',
resultField: 'period_name',
table: 'turma',
tableField: 'turma_turno_id',
resultField: 'period_id',
where: {
relation: '=',
type: 'integer',
field: 'id'
},
join: {
primary: 'id',
foreign: 'turno',
foreignTable: 'turma'
field: 'turma_turno_id'
}
}).addValue({
name: 'school',
......@@ -242,6 +219,6 @@ classApp.get('/', rqfCount.parse(), rqfCount.build(), (req, res, next) => {
.order('turma.ano_censo')
.where('turma.tipo_turma_id = 0 OR turma.tipo_turma_id = 1 OR turma.tipo_turma_id = 2 OR turma.tipo_turma_id = 3');
next();
}, query, response('class'));
}, query, id2str.transform(true), response('class'));
module.exports = classApp;
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