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