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

Merge branch 'development' into db_2013_2014_refactor

parents 013f20f6 e94d95e3
No related branches found
No related tags found
1 merge request!116Release v1.0.0
Pipeline #
......@@ -44,6 +44,8 @@ const oauth2 = require(`${libs}/middlewares/oauth2`);
const verifyToken = require(`${libs}/routes/verifyToken`);
const educationYears = require(`${libs}/routes/educationYears`);
api.get('/', (req, res) => {
res.json({ msg: 'SimCAQ API is running' });
});
......@@ -68,5 +70,6 @@ api.use('/population', population);
api.use('/idhml', idhml);
api.use('/auth/token', oauth2.token);
api.use('/verify', verifyToken);
api.use('/education_years', educationYears);
module.exports = api;
const express = require('express');
const educationYearsApp = express.Router();
const libs = `${process.cwd()}/libs`;
const log = require(`${libs}/log`)(module);
const response = require(`${libs}/middlewares/response`);
const config = require(`${libs}/config`);
const id2str = require(`${libs}/middlewares/id2str`);
const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
educationYearsApp.use(cache('15 day'));
educationYearsApp.get('/', (req, res, next) => {
req.result = [];
for(let i = 1; i <= 7; ++i) {
let edLvlShort = {
id: i,
name: id2str.educationLevelShort(i),
schoolYears: []
};
for(let j = i*10; j <= (i*10 + 9); ++j) {
let schoolYear = {
id: j,
name: id2str.schoolYear(j)
};
if(schoolYear.name !== id2str.schoolYear(99)) {
edLvlShort.schoolYears.push(schoolYear);
}
}
if(edLvlShort.name !== id2str.schoolYear(99)) {
req.result.push(edLvlShort);
}
}
next();
}, response('educationYears'));
module.exports = educationYearsApp;
......@@ -16,7 +16,7 @@ const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
const id2str = require(`${libs}/middlewares/id2str`);
const config = require(`${libs}/config`);
const config = require(`${libs}/config`);
const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
......@@ -59,8 +59,8 @@ rqf.addField({
}).addValue({
name: 'city',
table: 'municipio',
tableField: 'nome',
resultField: 'city_name',
tableField: ['nome', 'id'],
resultField: ['city_name', 'city_id'],
where: {
relation: '=',
type: 'integer',
......
......@@ -16,7 +16,7 @@ const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);
const id2str = require(`${libs}/middlewares/id2str`);
const config = require(`${libs}/config`);
const config = require(`${libs}/config`);
const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;
......@@ -61,8 +61,8 @@ rqf.addField({
}).addValue({
name: 'city',
table: 'municipio',
tableField: 'nome',
resultField: 'city_name',
tableField: ['nome', 'id'],
resultField: ['city_name', 'city_id'],
where: {
relation: '=',
type: 'integer',
......
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