From 800cb84165bc072322e63124bfe8a2540470b2c5 Mon Sep 17 00:00:00 2001 From: Vytor Calixto <vytorcalixto@gmail.com> Date: Wed, 22 Mar 2017 09:48:01 -0300 Subject: [PATCH] Change /location/sociodemographic to /spatial/sociodemographic Also included RQF. And /spatial/sociodemographic is usins RQF to build queries --- src/libs/routes/api.js | 4 +- src/libs/routes/{location.js => spatial.js} | 416 ++++---------------- src/test/{location.js => spatial.js} | 26 +- 3 files changed, 84 insertions(+), 362 deletions(-) rename src/libs/routes/{location.js => spatial.js} (72%) rename src/test/{location.js => spatial.js} (97%) diff --git a/src/libs/routes/api.js b/src/libs/routes/api.js index 2c29a246..ce905d8b 100644 --- a/src/libs/routes/api.js +++ b/src/libs/routes/api.js @@ -18,7 +18,7 @@ const city = require('./city'); const school = require('./school'); -const location = require('./location'); +const spatial = require('./spatial'); const simulation = require('./simulation'); @@ -36,6 +36,6 @@ api.use('/state', cache('15 day'), state); api.use('/region', cache('15 day'), region); api.use('/city', cache('15 day'), city); api.use('/school', cache('15 day'), school); -api.use('/location', cache('1 day'), location); +api.use('/spatial', cache('1 day'), spatial); module.exports = api; diff --git a/src/libs/routes/location.js b/src/libs/routes/spatial.js similarity index 72% rename from src/libs/routes/location.js rename to src/libs/routes/spatial.js index f5476f5e..34241b31 100644 --- a/src/libs/routes/location.js +++ b/src/libs/routes/spatial.js @@ -12,7 +12,11 @@ const sqlQuery = require(`${libs}/db/query_exec`); const response = require(`${libs}/middlewares/response`); -const locationApp = express(); +const spatialApp = express(); + +const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`); + +let rqf = new ReqQueryFields(); function locationIdToStr(locationId) { let locationStr = 'Total'; @@ -134,12 +138,60 @@ function dbExecAll(querySet = []) { return querySet.map((qry) => { return sqlQuery(qry.toString()); }); } -locationApp.get('/sociodemographic', (req, res, next) => { +rqf.addField({ + name: 'filter', + field: true, + where: true +}).addValue({ + name: 'region', + table: 'regiao', + tableField: 'nome', + resultField: 'region_name', + where: { + relation: '=', + type: 'integer', + field: 'id' + }, + join: { + primary: 'id', + foreign: 'regiao_id' + } +}).addValue({ + name: 'state', + table: 'estado', + tableField: 'nome', + resultField: 'estado_name', + where: { + relation: '=', + type: 'integer', + field: 'id' + }, + join: { + primary: 'id', + foreign: 'estado_id' + } +}).addValue({ + name: 'city', + table: 'municipio', + tableField: 'nome', + resultField: 'city_name', + where: { + relation: '=', + type: 'integer', + field: 'id' + }, + join: { + primary: 'id', + foreign: 'municipio_id' + } +}); + +spatialApp.get('/sociodemographic', rqf.parse(), rqf.build(), (req, res, next) => { const populationYearQry = squel.select() .field('MAX(ibge_populacao.ano_censo)') .from('ibge_populacao'); - const populationQry = squel.select() + const populationQry = req.sql.clone() .field('\'Brasil\'', 'name') .field('SUM(populacao)', 'population') .field('ibge_populacao.ano_censo', 'census_year') @@ -151,7 +203,7 @@ locationApp.get('/sociodemographic', (req, res, next) => { .field('MAX(ibge_pib.ano_censo)') .from('ibge_pib'); - const pibQry = squel.select() + const pibQry = req.sql.clone() .field('\'Brasil\'', 'name') .field('AVG(ibge_pib.pib_per_capita)', 'gdp_per_capita') .field('ibge_pib.ano_censo', 'census_year') @@ -163,7 +215,7 @@ locationApp.get('/sociodemographic', (req, res, next) => { .field('MAX(adh_idh.ano_censo)') .from('adh_idh'); - const idhQry = squel.select() + const idhQry = req.sql.clone() .field('\'Brasil\'', 'name') .field('AVG(idhm)', 'idhm') .field('adh_idh.ano_censo', 'census_year') @@ -175,7 +227,7 @@ locationApp.get('/sociodemographic', (req, res, next) => { .field('MAX(adh_analfabetismo.ano_censo)') .from('adh_analfabetismo'); - const analfabQry = squel.select() + const analfabQry = req.sql.clone() .field('\'Brasil\'', 'name') .field('AVG(t_analf15m)', 'analfabetism') .field('adh_analfabetismo.ano_censo', 'census_year') @@ -187,7 +239,7 @@ locationApp.get('/sociodemographic', (req, res, next) => { .field('MAX(adh_gini.ano_censo)') .from('adh_gini'); - const giniQry = squel.select() + const giniQry = req.sql.clone() .field('\'Brasil\'', 'name') .field('AVG(gini)', 'gini') .field('adh_gini.ano_censo', 'census_year') @@ -206,339 +258,9 @@ locationApp.get('/sociodemographic', (req, res, next) => { log.error(`[SQL query error] ${error}`); next(error); }); -}, response('location')); - -locationApp.get('/sociodemographic/region/:id', (req, res, next) => { - const regionId = parseInt(req.params.id, 10); - - const populationYearQry = squel.select() - .field('MAX(ibge_populacao.ano_censo)') - .from('ibge_populacao'); - - const populationQry = squel.select() - .field('regiao.nome', 'name') - .field('SUM(populacao)', 'population') - .field('ano_censo', 'census_year') - .from('ibge_populacao') - .from('municipio') - .from('estado') - .from('regiao') - .where(`regiao.pk_regiao_id = ${regionId}`) - .where(`ibge_populacao.ano_censo IN (${populationYearQry.toString()})`) - .where('ibge_populacao.fk_municipio_id = municipio.pk_cod_ibge') - .where('municipio.fk_estado_id = estado.pk_estado_id') - .where('estado.fk_regiao_id = regiao.pk_regiao_id') - .group('regiao.nome') - .group('ibge_populacao.ano_censo') - .order('regiao.nome'); - - const pibYearQry = squel.select() - .field('MAX(ibge_pib.ano_censo)') - .from('ibge_pib'); - - const pibQry = squel.select() - .field('regiao.nome', 'name') - .field('AVG(ibge_pib.pib_per_capita)', 'gdp_per_capita') - .field('ano_censo', 'census_year') - .from('ibge_pib') - .from('municipio') - .from('estado') - .from('regiao') - .where(`regiao.pk_regiao_id = ${regionId}`) - .where(`ibge_pib.ano_censo IN (${pibYearQry.toString()})`) - .where('ibge_pib.fk_municipio_id = municipio.pk_cod_ibge') - .where('municipio.fk_estado_id = estado.pk_estado_id') - .where('estado.fk_regiao_id = regiao.pk_regiao_id') - .group('regiao.nome') - .group('ibge_pib.ano_censo') - .order('regiao.nome'); - - const idhYearQry = squel.select() - .field('MAX(adh_idh.ano_censo)') - .from('adh_idh'); - - const idhQry = squel.select() - .field('regiao.nome', 'name') - .field('AVG(idhm)', 'idhm') - .field('ano_censo', 'census_year') - .from('adh_idh') - .from('municipio') - .from('estado') - .from('regiao') - .where(`regiao.pk_regiao_id = ${regionId}`) - .where(`adh_idh.ano_censo IN (${idhYearQry.toString()})`) - .where('adh_idh.fk_municipio_id = municipio.pk_cod_ibge') - .where('municipio.fk_estado_id = estado.pk_estado_id') - .where('estado.fk_regiao_id = regiao.pk_regiao_id') - .group('regiao.nome') - .group('adh_idh.ano_censo') - .order('regiao.nome'); - - const analfabYearQry = squel.select() - .field('MAX(adh_analfabetismo.ano_censo)') - .from('adh_analfabetismo'); - - const analfabQry = squel.select() - .field('regiao.nome', 'name') - .field('AVG(t_analf15m)', 'analfabetism') - .field('ano_censo', 'census_year') - .from('adh_analfabetismo') - .from('municipio') - .from('estado') - .from('regiao') - .where(`regiao.pk_regiao_id = ${regionId}`) - .where(`adh_analfabetismo.ano_censo IN (${analfabYearQry.toString()})`) - .where('adh_analfabetismo.fk_municipio_id = municipio.pk_cod_ibge') - .where('municipio.fk_estado_id = estado.pk_estado_id') - .where('estado.fk_regiao_id = regiao.pk_regiao_id') - .group('regiao.nome') - .group('adh_analfabetismo.ano_censo') - .order('regiao.nome'); - - const giniYearQry = squel.select() - .field('MAX(adh_gini.ano_censo)') - .from('adh_gini'); - - const giniQry = squel.select() - .field('regiao.nome', 'name') - .field('AVG(gini)', 'gini') - .field('ano_censo', 'census_year') - .from('adh_gini') - .from('municipio') - .from('estado') - .from('regiao') - .where(`regiao.pk_regiao_id = ${regionId}`) - .where(`adh_gini.ano_censo IN (${giniYearQry.toString()})`) - .where('adh_gini.fk_municipio_id = municipio.pk_cod_ibge') - .where('municipio.fk_estado_id = estado.pk_estado_id') - .where('estado.fk_regiao_id = regiao.pk_regiao_id') - .group('regiao.nome') - .group('adh_gini.ano_censo') - .order('regiao.nome'); - // map query objects to their respective response labels - const queryLabels = [ "population", "gdp", "idh", "analfab", "gini" ]; - const querySet = [ populationQry, pibQry, idhQry, analfabQry, giniQry ]; - // wait until all queries finish or one of them fail - Promise.all(dbExecAll(querySet)).then((queryResults) => { - req.result = processResultSet(queryResults, queryLabels, true); - next(); - }).catch((error) => { - log.error(`[SQL query error] ${error}`); - next(error); - }); -}, response('location')); - -locationApp.get('/sociodemographic/state/:id', (req, res, next) => { - const stateId = parseInt(req.params.id, 10); - - const populationYearQry = squel.select() - .field('MAX(ibge_populacao.ano_censo)') - .from('ibge_populacao'); - // load all cities by state and compute the sociodemographic and educational information - const populationQry = squel.select() - .field('estado.nome', 'name') - .field('SUM(populacao)', 'population') - .field('ibge_populacao.ano_censo', 'census_year') - .from('ibge_populacao') - .from('municipio') - .from('estado') - .where(`estado.pk_estado_id = ${stateId}`) - .where(`ibge_populacao.ano_censo IN (${populationYearQry.toString()})`) - .where('ibge_populacao.fk_municipio_id = municipio.pk_cod_ibge') - .where('municipio.fk_estado_id = estado.pk_estado_id') - .group('estado.nome') - .group('ibge_populacao.ano_censo') - .order('estado.nome'); - - const pibYearQry = squel.select() - .field('MAX(ibge_pib.ano_censo)') - .from('ibge_pib'); - - const pibQry = squel.select() - .field('estado.nome', 'name') - .field('AVG(ibge_pib.pib_per_capita)', 'gdp_per_capita') - .field('ibge_pib.ano_censo', 'census_year') - .from('ibge_pib') - .from('municipio') - .from('estado') - .where(`estado.pk_estado_id = ${stateId}`) - .where(`ibge_pib.ano_censo IN (${pibYearQry.toString()})`) - .where('ibge_pib.fk_municipio_id = municipio.pk_cod_ibge') - .where('municipio.fk_estado_id = estado.pk_estado_id') - .group('estado.nome') - .group('ibge_pib.ano_censo') - .order('estado.nome'); - - const idhYearQry = squel.select() - .field('MAX(adh_idh.ano_censo)') - .from('adh_idh'); - - const idhQry = squel.select() - .field('estado.nome', 'name') - .field('AVG(idhm)', 'idhm') - .field('adh_idh.ano_censo', 'census_year') - .from('adh_idh') - .from('municipio') - .from('estado') - .where(`estado.pk_estado_id = ${stateId}`) - .where(`adh_idh.ano_censo IN (${idhYearQry.toString()})`) - .where('adh_idh.fk_municipio_id = municipio.pk_cod_ibge') - .where('municipio.fk_estado_id = estado.pk_estado_id') - .group('estado.nome') - .group('adh_idh.ano_censo') - .order('estado.nome'); - - const analfabYearQry = squel.select() - .field('MAX(adh_analfabetismo.ano_censo)') - .from('adh_analfabetismo'); - - const analfabQry = squel.select() - .field('estado.nome', 'name') - .field('AVG(t_analf15m)', 'analfabetism') - .field('adh_analfabetismo.ano_censo', 'census_year') - .from('adh_analfabetismo') - .from('municipio') - .from('estado') - .where(`estado.pk_estado_id = ${stateId}`) - .where(`adh_analfabetismo.ano_censo IN (${analfabYearQry.toString()})`) - .where('adh_analfabetismo.fk_municipio_id = municipio.pk_cod_ibge') - .where('municipio.fk_estado_id = estado.pk_estado_id') - .group('estado.nome') - .group('adh_analfabetismo.ano_censo') - .order('estado.nome'); - - const giniYearQry = squel.select() - .field('MAX(adh_gini.ano_censo)') - .from('adh_gini'); - - const giniQry = squel.select() - .field('estado.nome', 'name') - .field('AVG(gini)', 'gini') - .field('adh_gini.ano_censo', 'census_year') - .from('adh_gini') - .from('municipio') - .from('estado') - .where(`estado.pk_estado_id = ${stateId}`) - .where(`adh_gini.ano_censo IN (${giniYearQry.toString()})`) - .where('adh_gini.fk_municipio_id = municipio.pk_cod_ibge') - .where('municipio.fk_estado_id = estado.pk_estado_id') - .group('estado.nome') - .group('adh_gini.ano_censo') - .order('estado.nome'); - // map query objects to their respective response labels - const queryLabels = [ "population", "gdp", "idh", "analfab", "gini" ]; - const querySet = [ populationQry, pibQry, idhQry, analfabQry, giniQry ]; - // wait until all queries finish or one of them fail - Promise.all(dbExecAll(querySet)).then((queryResults) => { - req.result = processResultSet(queryResults, queryLabels, true); - next(); - }).catch((error) => { - log.error(`[SQL query error] ${error}`); - next(error); - }); -}, response('location')); - -locationApp.get('/sociodemographic/city/:id', (req, res, next) => { - const cityId = parseInt(req.params.id, 10); - - const populationYearQry = squel.select() - .field('MAX(ibge_populacao.ano_censo)') - .from('ibge_populacao'); - // load all cities by state and compute the sociodemographic and educational information - const populationQry = squel.select() - .field('municipio.nome', 'name') - .field('SUM(populacao)', 'population') - .field('ibge_populacao.ano_censo', 'census_year') - .from('ibge_populacao') - .from('municipio') - .where(`municipio.pk_cod_ibge = ${cityId}`) - .where(`ibge_populacao.ano_censo IN (${populationYearQry.toString()})`) - .where('ibge_populacao.fk_municipio_id = municipio.pk_cod_ibge') - .group('municipio.nome') - .group('ibge_populacao.ano_censo') - .order('municipio.nome'); - - const pibYearQry = squel.select() - .field('MAX(ibge_pib.ano_censo)') - .from('ibge_pib'); - - const pibQry = squel.select() - .field('municipio.nome', 'name') - .field('AVG(ibge_pib.pib_per_capita)', 'gdp_per_capita') - .field('ibge_pib.ano_censo', 'census_year') - .from('ibge_pib') - .from('municipio') - .where(`municipio.pk_cod_ibge = ${cityId}`) - .where(`ibge_pib.ano_censo IN (${pibYearQry.toString()})`) - .where('ibge_pib.fk_municipio_id = municipio.pk_cod_ibge') - .group('municipio.nome') - .group('ibge_pib.ano_censo') - .order('municipio.nome'); - - const idhYearQry = squel.select() - .field('MAX(adh_idh.ano_censo)') - .from('adh_idh'); - - const idhQry = squel.select() - .field('municipio.nome', 'name') - .field('AVG(idhm)', 'idhm') - .field('adh_idh.ano_censo', 'census_year') - .from('adh_idh') - .from('municipio') - .where(`municipio.pk_cod_ibge = ${cityId}`) - .where(`adh_idh.ano_censo IN (${idhYearQry.toString()})`) - .where('adh_idh.fk_municipio_id = municipio.pk_cod_ibge') - .group('municipio.nome') - .group('adh_idh.ano_censo') - .order('municipio.nome'); - - const analfabYearQry = squel.select() - .field('MAX(adh_analfabetismo.ano_censo)') - .from('adh_analfabetismo'); - - const analfabQry = squel.select() - .field('municipio.nome', 'name') - .field('AVG(t_analf15m)', 'analfabetism') - .field('adh_analfabetismo.ano_censo', 'census_year') - .from('adh_analfabetismo') - .from('municipio') - .where(`municipio.pk_cod_ibge = ${cityId}`) - .where(`adh_analfabetismo.ano_censo IN (${analfabYearQry.toString()})`) - .where('adh_analfabetismo.fk_municipio_id = municipio.pk_cod_ibge') - .group('municipio.nome') - .group('adh_analfabetismo.ano_censo') - .order('municipio.nome'); - - const giniYearQry = squel.select() - .field('MAX(adh_gini.ano_censo)') - .from('adh_gini'); - - const giniQry = squel.select() - .field('municipio.nome', 'name') - .field('AVG(gini)', 'gini') - .field('adh_gini.ano_censo', 'census_year') - .from('adh_gini') - .from('municipio') - .where(`municipio.pk_cod_ibge = ${cityId}`) - .where(`adh_gini.ano_censo IN (${giniYearQry.toString()})`) - .where('adh_gini.fk_municipio_id = municipio.pk_cod_ibge') - .group('municipio.nome') - .group('adh_gini.ano_censo') - .order('municipio.nome'); - // map query objects to their respective response labels - const queryLabels = [ "population", "gdp", "idh", "analfab", "gini" ]; - const querySet = [ populationQry, pibQry, idhQry, analfabQry, giniQry ]; - // wait until all queries finish or one of them fail - Promise.all(dbExecAll(querySet)).then((queryResults) => { - req.result = processResultSet(queryResults, queryLabels, true); - next(); - }).catch((error) => { - log.error(`[SQL query error] ${error}`); - next(error); - }); -}, response('location')); +}, response('spatial')); -locationApp.get('/educational', (req, res, next) => { +spatialApp.get('/educational', (req, res, next) => { const censusYearQry = squel.select() .field('MAX(escola.ano_censo)', 'ano_censo') .from('escola') @@ -630,7 +352,7 @@ locationApp.get('/educational', (req, res, next) => { }); }, response('location')); -locationApp.get('/educational/region/:id', (req, res, next) => { +spatialApp.get('/educational/region/:id', (req, res, next) => { const regionId = parseInt(req.params.id, 10); const censusYearQry = squel.select() @@ -753,7 +475,7 @@ locationApp.get('/educational/region/:id', (req, res, next) => { }); }, response('location')); -locationApp.get('/educational/state/:id', (req, res, next) => { +spatialApp.get('/educational/state/:id', (req, res, next) => { const stateId = parseInt(req.params.id, 10); const censusYearQry = squel.select() @@ -872,7 +594,7 @@ locationApp.get('/educational/state/:id', (req, res, next) => { }); }, response('location')); -locationApp.get('/educational/city/:id', (req, res, next) => { +spatialApp.get('/educational/city/:id', (req, res, next) => { const cityId = parseInt(req.params.id, 10); const censusYearQry = squel.select() @@ -991,7 +713,7 @@ locationApp.get('/educational/city/:id', (req, res, next) => { }); }, response('location')); -locationApp.get('/educational/school_level', (req, res, next) => { +spatialApp.get('/educational/school_level', (req, res, next) => { const enrollmentsPerSchoolLevelYearQry = squel.select() .field('MAX(turma.ano_censo)', 'census_year') .from('turma'); @@ -1057,7 +779,7 @@ locationApp.get('/educational/school_level', (req, res, next) => { }); }, response('location')); -locationApp.get('/educational/school_level/region/:id', (req, res, next) => { +spatialApp.get('/educational/school_level/region/:id', (req, res, next) => { const regionId = parseInt(req.params.id, 10); const enrollmentsPerSchoolLevelYearQry = squel.select() @@ -1130,7 +852,7 @@ locationApp.get('/educational/school_level/region/:id', (req, res, next) => { }); }, response('location')); -locationApp.get('/educational/school_level/state/:id', (req, res, next) => { +spatialApp.get('/educational/school_level/state/:id', (req, res, next) => { const stateId = parseInt(req.params.id, 10); const enrollmentsPerSchoolLevelYearQry = squel.select() @@ -1203,7 +925,7 @@ locationApp.get('/educational/school_level/state/:id', (req, res, next) => { }); }, response('location')); -locationApp.get('/educational/school_level/city/:id', (req, res, next) => { +spatialApp.get('/educational/school_level/city/:id', (req, res, next) => { const cityId = parseInt(req.params.id, 10); const enrollmentsPerSchoolLevelYearQry = squel.select() @@ -1276,4 +998,4 @@ locationApp.get('/educational/school_level/city/:id', (req, res, next) => { }); }, response('location')); -module.exports = locationApp; +module.exports = spatialApp; diff --git a/src/test/location.js b/src/test/spatial.js similarity index 97% rename from src/test/location.js rename to src/test/spatial.js index 42761a8d..b0e53083 100644 --- a/src/test/location.js +++ b/src/test/spatial.js @@ -26,10 +26,10 @@ chai.use(chaiHttp); const testTimeout = 5000; -describe('test location', () => { +describe('test spatial', () => { it('should return the expected response format for sociodemographic data for the whole country', (done) => { chai.request(server) - .get('/api/v1/location/sociodemographic') + .get('/api/v1/spatial/sociodemographic') .end((err, res) => { res.should.have.status(200); // test response format @@ -69,7 +69,7 @@ describe('test location', () => { it('should return the expected response format for sociodemographic data for a region', (done) => { chai.request(server) - .get('/api/v1/location/sociodemographic/region/1') + .get('/api/v1/spatial/sociodemographic?filter=region:1') .end((err, res) => { res.should.have.status(200); // test response format @@ -109,7 +109,7 @@ describe('test location', () => { it('should return the expected response format for sociodemographic data for a state', (done) => { chai.request(server) - .get('/api/v1/location/sociodemographic/state/42') + .get('/api/v1/spatial/sociodemographic?filter=state:42') .end((err, res) => { res.should.have.status(200); // test response format @@ -149,7 +149,7 @@ describe('test location', () => { it('should return the expected response format for sociodemographic data for a city', (done) => { chai.request(server) - .get('/api/v1/location/sociodemographic/city/4106902') + .get('/api/v1/spatial/sociodemographic?filter=city:4106902') .end((err, res) => { res.should.have.status(200); // test response format @@ -189,7 +189,7 @@ describe('test location', () => { it('should return the expected response format for educational data for the whole country', (done) => { chai.request(server) - .get('/api/v1/location/educational') + .get('/api/v1/spatial/educational') .end((err, res) => { res.should.have.status(200); // test response format @@ -254,7 +254,7 @@ describe('test location', () => { it('should return the expected response format for educational data for a country region', (done) => { chai.request(server) - .get('/api/v1/location/educational/region/1') + .get('/api/v1/spatial/educational/region/1') .end((err, res) => { res.should.have.status(200); // test response format @@ -319,7 +319,7 @@ describe('test location', () => { it('should return the expected response format for educational data for a country state', (done) => { chai.request(server) - .get('/api/v1/location/educational/state/42') + .get('/api/v1/spatial/educational/state/42') .end((err, res) => { res.should.have.status(200); // test response format @@ -384,7 +384,7 @@ describe('test location', () => { it('should return the expected response format for educational data for a country city', (done) => { chai.request(server) - .get('/api/v1/location/educational/city/4106902') + .get('/api/v1/spatial/educational/city/4106902') .end((err, res) => { res.should.have.status(200); // test response format @@ -449,7 +449,7 @@ describe('test location', () => { it('should return the correct format of enrollments per school level', (done) => { chai.request(server) - .get('/api/v1/location/educational/school_level') + .get('/api/v1/spatial/educational/school_level') .end((err, res) => { res.should.have.status(200); // test response format @@ -478,7 +478,7 @@ describe('test location', () => { it('should return the correct format of enrollments per school level for a region', (done) => { chai.request(server) - .get('/api/v1/location/educational/school_level/region/1') + .get('/api/v1/spatial/educational/school_level/region/1') .end((err, res) => { res.should.have.status(200); // test response format @@ -507,7 +507,7 @@ describe('test location', () => { it('should return the correct format of enrollments per school level for a state', (done) => { chai.request(server) - .get('/api/v1/location/educational/school_level/state/42') + .get('/api/v1/spatial/educational/school_level/state/42') .end((err, res) => { res.should.have.status(200); // test response format @@ -536,7 +536,7 @@ describe('test location', () => { it('should return the correct format of enrollments per school level for a city', (done) => { chai.request(server) - .get('/api/v1/location/educational/school_level/state/4106902') + .get('/api/v1/spatial/educational/school_level/state/4106902') .end((err, res) => { res.should.have.status(200); // test response format -- GitLab