diff --git a/src/libs/routes/class.js b/src/libs/routes/class.js index dc0f02588ef387ad7fb6d6503773754de4a54af5..6f7a74572a3da02519d60265c7ea6ae7bb2483d6 100644 --- a/src/libs/routes/class.js +++ b/src/libs/routes/class.js @@ -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;