Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
simcaq-node
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Harbor Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
simcaq
simcaq-node
Commits
29110380
There was a problem fetching the pipeline summary.
Commit
29110380
authored
8 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Fix SQL and tests for /spatial
parent
48c999e1
No related branches found
No related tags found
2 merge requests
!116
Release v1.0.0
,
!34
Db simcaq dev2
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libs/routes/spatial.js
+5
-5
5 additions, 5 deletions
src/libs/routes/spatial.js
src/test/spatial.js
+23
-24
23 additions, 24 deletions
src/test/spatial.js
with
28 additions
and
29 deletions
src/libs/routes/spatial.js
+
5
−
5
View file @
29110380
...
...
@@ -303,8 +303,8 @@ spatialApp.get('/educational', rqf.parse(), rqf.build(), (req, res, next) => {
.
field
(
'
COALESCE(COUNT(matricula.id), 0)
'
,
'
total
'
)
.
field
(
'
matricula.ano_censo
'
,
'
census_year
'
)
.
field
(
'
dependencia_adm.nome
'
,
'
adm_dependency_name
'
)
.
from
(
'
matricula
'
)
.
from
(
'
dependencia_adm
'
)
.
from
(
'
matricula
'
)
.
where
(
'
matricula.dependencia_adm_id=dependencia_adm.id
'
)
.
where
(
'
matricula.tipo <= 3
'
)
.
where
(
`matricula.ano_censo IN (
${
schoolClassYearQry
}
)`
)
...
...
@@ -317,8 +317,8 @@ spatialApp.get('/educational', rqf.parse(), rqf.build(), (req, res, next) => {
.
field
(
'
COALESCE(COUNT(matricula.id), 0)
'
,
'
total
'
)
.
field
(
'
matricula.ano_censo
'
,
'
census_year
'
)
.
field
(
'
etapa_ensino.desc_etapa
'
,
'
school_level_name
'
)
.
from
(
'
matricula
'
)
.
from
(
'
etapa_ensino
'
)
.
from
(
'
matricula
'
)
.
where
(
'
matricula.etapa_ensino_id=etapa_ensino.id
'
)
.
where
(
'
matricula.tipo <= 3
'
)
.
where
(
`matricula.ano_censo IN (
${
schoolClassYearQry
}
)`
)
...
...
@@ -341,18 +341,18 @@ spatialApp.get('/educational', rqf.parse(), rqf.build(), (req, res, next) => {
});
},
response
(
'
spatial
'
));
spatialApp
.
get
(
'
/educational/school_level
'
,
(
req
,
res
,
next
)
=>
{
spatialApp
.
get
(
'
/educational/school_level
'
,
rqf
.
parse
(),
rqf
.
build
(),
(
req
,
res
,
next
)
=>
{
const
enrollmentsPerSchoolLevelYearQry
=
squel
.
select
()
.
field
(
'
MAX(matricula.ano_censo)
'
,
'
census_year
'
)
.
from
(
'
matricula
'
);
const
enrollmentsPerSchoolLevelQry
=
squel
.
select
()
const
enrollmentsPerSchoolLevelQry
=
req
.
sql
.
clone
()
.
field
(
'
COALESCE(COUNT(matricula.id), 0)
'
,
'
total
'
)
.
field
(
'
matricula.ano_censo
'
,
'
census_year
'
)
.
field
(
'
matricula.serie_ano_id
'
,
'
school_year
'
)
.
field
(
'
etapa_ensino.desc_etapa
'
,
'
school_level
'
)
.
from
(
'
matricula
'
)
.
from
(
'
etapa_ensino
'
)
.
from
(
'
matricula
'
)
.
where
(
`matricula.ano_censo IN (
${
enrollmentsPerSchoolLevelYearQry
.
toString
()}
)`
)
.
where
(
'
matricula.etapa_ensino_id = etapa_ensino.id
'
)
.
where
(
'
matricula.tipo <= 3
'
)
...
...
This diff is collapsed.
Click to expand it.
src/test/spatial.js
+
23
−
24
View file @
29110380
...
...
@@ -24,7 +24,7 @@ const server = require(`${libs}/app`);
chai
.
use
(
chaiHttp
);
const
testTimeout
=
5
000
;
const
testTimeout
=
60
000
;
describe
(
'
test spatial
'
,
()
=>
{
it
(
'
should return the expected response format for sociodemographic data for the whole country
'
,
(
done
)
=>
{
...
...
@@ -209,11 +209,10 @@ describe('test spatial', () => {
res
.
body
.
result
.
should
.
have
.
property
(
'
enrollment_per_school_level
'
);
res
.
body
.
result
.
enrollment_per_school_level
.
should
.
be
.
a
(
'
array
'
);
// test response attributes for school
res
.
body
.
result
.
school
.
should
.
a
(
'
array
'
);
res
.
body
.
result
.
school
.
forEach
((
row
)
=>
{
row
.
should
.
be
.
a
(
'
object
'
);
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
location
'
);
row
.
should
.
have
.
property
(
'
location
_name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
});
...
...
@@ -221,7 +220,7 @@ describe('test spatial', () => {
res
.
body
.
result
.
school_per_location
.
forEach
((
row
)
=>
{
row
.
should
.
be
.
a
(
'
object
'
);
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
location
'
);
row
.
should
.
have
.
property
(
'
location
_name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
});
...
...
@@ -238,7 +237,7 @@ describe('test spatial', () => {
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
row
.
should
.
have
.
property
(
'
adm_dependency
'
);
row
.
should
.
have
.
property
(
'
adm_dependency
_name
'
);
});
// test response attributes for enrollment_per_school_level
res
.
body
.
result
.
enrollment_per_school_level
.
forEach
((
row
)
=>
{
...
...
@@ -246,7 +245,7 @@ describe('test spatial', () => {
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
row
.
should
.
have
.
property
(
'
school_level
'
);
row
.
should
.
have
.
property
(
'
school_level
_name
'
);
});
done
();
});
...
...
@@ -254,7 +253,7 @@ describe('test spatial', () => {
it
(
'
should return the expected response format for educational data for a country region
'
,
(
done
)
=>
{
chai
.
request
(
server
)
.
get
(
'
/api/v1/spatial/educational
/
region
/
1
'
)
.
get
(
'
/api/v1/spatial/educational
?filter=
region
:
1
'
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
// test response format
...
...
@@ -278,7 +277,7 @@ describe('test spatial', () => {
res
.
body
.
result
.
school
.
forEach
((
row
)
=>
{
row
.
should
.
be
.
a
(
'
object
'
);
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
location
'
);
row
.
should
.
have
.
property
(
'
location
_name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
});
...
...
@@ -286,7 +285,7 @@ describe('test spatial', () => {
res
.
body
.
result
.
school_per_location
.
forEach
((
row
)
=>
{
row
.
should
.
be
.
a
(
'
object
'
);
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
location
'
);
row
.
should
.
have
.
property
(
'
location
_name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
});
...
...
@@ -303,7 +302,7 @@ describe('test spatial', () => {
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
row
.
should
.
have
.
property
(
'
adm_dependency
'
);
row
.
should
.
have
.
property
(
'
adm_dependency
_name
'
);
});
// test response attributes for enrollment_per_school_level
res
.
body
.
result
.
enrollment_per_school_level
.
forEach
((
row
)
=>
{
...
...
@@ -311,7 +310,7 @@ describe('test spatial', () => {
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
row
.
should
.
have
.
property
(
'
school_level
'
);
row
.
should
.
have
.
property
(
'
school_level
_name
'
);
});
done
();
});
...
...
@@ -319,7 +318,7 @@ describe('test spatial', () => {
it
(
'
should return the expected response format for educational data for a country state
'
,
(
done
)
=>
{
chai
.
request
(
server
)
.
get
(
'
/api/v1/spatial/educational
/
state
/
42
'
)
.
get
(
'
/api/v1/spatial/educational
?filter=
state
:
42
'
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
// test response format
...
...
@@ -343,7 +342,7 @@ describe('test spatial', () => {
res
.
body
.
result
.
school
.
forEach
((
row
)
=>
{
row
.
should
.
be
.
a
(
'
object
'
);
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
location
'
);
row
.
should
.
have
.
property
(
'
location
_name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
});
...
...
@@ -351,7 +350,7 @@ describe('test spatial', () => {
res
.
body
.
result
.
school_per_location
.
forEach
((
row
)
=>
{
row
.
should
.
be
.
a
(
'
object
'
);
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
location
'
);
row
.
should
.
have
.
property
(
'
location
_name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
});
...
...
@@ -368,7 +367,7 @@ describe('test spatial', () => {
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
row
.
should
.
have
.
property
(
'
adm_dependency
'
);
row
.
should
.
have
.
property
(
'
adm_dependency
_name
'
);
});
// test response attributes for enrollment_per_school_level
res
.
body
.
result
.
enrollment_per_school_level
.
forEach
((
row
)
=>
{
...
...
@@ -376,7 +375,7 @@ describe('test spatial', () => {
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
row
.
should
.
have
.
property
(
'
school_level
'
);
row
.
should
.
have
.
property
(
'
school_level
_name
'
);
});
done
();
});
...
...
@@ -384,7 +383,7 @@ describe('test spatial', () => {
it
(
'
should return the expected response format for educational data for a country city
'
,
(
done
)
=>
{
chai
.
request
(
server
)
.
get
(
'
/api/v1/spatial/educational
/
city
/
4106902
'
)
.
get
(
'
/api/v1/spatial/educational
?filter=
city
:
4106902
'
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
// test response format
...
...
@@ -408,7 +407,7 @@ describe('test spatial', () => {
res
.
body
.
result
.
school
.
forEach
((
row
)
=>
{
row
.
should
.
be
.
a
(
'
object
'
);
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
location
'
);
row
.
should
.
have
.
property
(
'
location
_name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
});
...
...
@@ -416,7 +415,7 @@ describe('test spatial', () => {
res
.
body
.
result
.
school_per_location
.
forEach
((
row
)
=>
{
row
.
should
.
be
.
a
(
'
object
'
);
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
location
'
);
row
.
should
.
have
.
property
(
'
location
_name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
});
...
...
@@ -433,7 +432,7 @@ describe('test spatial', () => {
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
row
.
should
.
have
.
property
(
'
adm_dependency
'
);
row
.
should
.
have
.
property
(
'
adm_dependency
_name
'
);
});
// test response attributes for enrollment_per_school_level
res
.
body
.
result
.
enrollment_per_school_level
.
forEach
((
row
)
=>
{
...
...
@@ -441,7 +440,7 @@ describe('test spatial', () => {
row
.
should
.
have
.
property
(
'
name
'
);
row
.
should
.
have
.
property
(
'
total
'
);
row
.
should
.
have
.
property
(
'
census_year
'
);
row
.
should
.
have
.
property
(
'
school_level
'
);
row
.
should
.
have
.
property
(
'
school_level
_name
'
);
});
done
();
});
...
...
@@ -478,7 +477,7 @@ describe('test spatial', () => {
it
(
'
should return the correct format of enrollments per school level for a region
'
,
(
done
)
=>
{
chai
.
request
(
server
)
.
get
(
'
/api/v1/spatial/educational/school_level
/
region
/
1
'
)
.
get
(
'
/api/v1/spatial/educational/school_level
?filter=
region
:
1
'
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
// test response format
...
...
@@ -507,7 +506,7 @@ describe('test spatial', () => {
it
(
'
should return the correct format of enrollments per school level for a state
'
,
(
done
)
=>
{
chai
.
request
(
server
)
.
get
(
'
/api/v1/spatial/educational/school_level
/
state
/
42
'
)
.
get
(
'
/api/v1/spatial/educational/school_level
?filter=
state
:
42
'
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
// test response format
...
...
@@ -536,7 +535,7 @@ describe('test spatial', () => {
it
(
'
should return the correct format of enrollments per school level for a city
'
,
(
done
)
=>
{
chai
.
request
(
server
)
.
get
(
'
/api/v1/spatial/educational/school_level
/state/
4106902
'
)
.
get
(
'
/api/v1/spatial/educational/school_level
?filter=city:
4106902
'
)
.
end
((
err
,
res
)
=>
{
res
.
should
.
have
.
status
(
200
);
// test response format
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment