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
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
d2735617
There was a problem fetching the pipeline summary.
Commit
d2735617
authored
8 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Add schools_per_adm_dependency and enrollment_per_location at /spatial/educational
parent
d9837161
No related branches found
No related tags found
2 merge requests
!116
Release v1.0.0
,
!34
Db simcaq dev2
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libs/routes/spatial.js
+38
-9
38 additions, 9 deletions
src/libs/routes/spatial.js
with
38 additions
and
9 deletions
src/libs/routes/spatial.js
+
38
−
9
View file @
d2735617
...
...
@@ -260,8 +260,8 @@ spatialApp.get('/educational', rqf.parse(), rqf.build(), (req, res, next) => {
.
field
(
'
\'
Total
\'
'
,
'
location_name
'
)
.
field
(
'
COUNT(DISTINCT(escola.id))
'
,
'
total
'
)
.
field
(
'
escola.ano_censo
'
,
'
census_year
'
)
.
from
(
'
escola
'
)
.
from
(
'
turma
'
)
.
from
(
'
escola
'
)
.
where
(
'
escola.ano_censo=turma.ano_censo AND escola.id=turma.escola_id
'
)
.
where
(
`escola.ano_censo IN (
${
censusYearQry
}
)`
)
.
where
(
'
turma.tipo_turma_id = 0
'
)
...
...
@@ -272,10 +272,10 @@ spatialApp.get('/educational', rqf.parse(), rqf.build(), (req, res, next) => {
.
field
(
'
COUNT(DISTINCT(escola.id))
'
,
'
total
'
)
.
field
(
'
escola.ano_censo
'
,
'
census_year
'
)
.
field
(
'
localizacao.descricao
'
,
'
location_name
'
)
.
from
(
'
escola
'
)
.
from
(
'
localizacao
'
)
.
where
(
'
escola.cod_localizacao=localizacao.id
'
)
.
from
(
'
turma
'
)
.
from
(
'
escola
'
)
.
where
(
'
escola.cod_localizacao=localizacao.id
'
)
.
where
(
'
escola.ano_censo=turma.ano_censo AND escola.id=turma.escola_id
'
)
.
where
(
`escola.ano_censo IN (
${
censusYearQry
}
)`
)
.
where
(
'
turma.tipo_turma_id = 0
'
)
...
...
@@ -284,9 +284,23 @@ spatialApp.get('/educational', rqf.parse(), rqf.build(), (req, res, next) => {
.
group
(
'
localizacao.descricao
'
)
.
order
(
'
localizacao.descricao
'
);
const
schoolsPerAdmDependencyQry
=
req
.
sql
.
clone
()
.
field
(
'
\'
Brasil
\'
'
,
'
name
'
)
.
field
(
'
COUNT(DISTINCT(escola.id))
'
,
'
total
'
)
.
field
(
'
escola.ano_censo
'
,
'
census_year
'
)
.
field
(
'
dependencia_adm.nome
'
,
'
adm_dependency_name
'
)
.
from
(
'
dependencia_adm
'
)
.
from
(
'
escola
'
)
.
where
(
'
escola.dependencia_adm_id=dependencia_adm.id
'
)
.
where
(
`escola.ano_censo IN (
${
censusYearQry
}
)`
)
.
group
(
'
escola.ano_censo
'
)
.
group
(
'
dependencia_adm.nome
'
)
.
order
(
'
escola.ano_censo
'
)
.
order
(
'
dependencia_adm.nome
'
);
const
schoolClassYearQry
=
squel
.
select
()
.
field
(
'
MAX(
turm
a.ano_censo)
'
)
.
from
(
'
turm
a
'
)
.
field
(
'
MAX(
matricul
a.ano_censo)
'
)
.
from
(
'
matricul
a
'
)
.
toString
();
const
enrollmentsQry
=
req
.
sql
.
clone
()
...
...
@@ -327,10 +341,25 @@ spatialApp.get('/educational', rqf.parse(), rqf.build(), (req, res, next) => {
.
group
(
'
etapa_ensino.id
'
)
.
order
(
'
etapa_ensino.id
'
);
const
queryLabels
=
[
"
school
"
,
"
school_per_location
"
,
"
enrollment
"
,
"
enrollment_per_adm_dep
"
,
"
enrollment_per_school_level
"
];
const
querySet
=
[
totalSchoolsQry
,
schoolsPerLocationQry
,
enrollmentsQry
,
enrollmentsPerAdmDepQry
,
enrollmentsPerSchoolLevelQry
];
const
enrollmentsPerLocationQry
=
req
.
sql
.
clone
()
.
field
(
'
\'
Brasil
\'
'
,
'
name
'
)
.
field
(
'
COALESCE(COUNT(matricula.id), 0)
'
,
'
total
'
)
.
field
(
'
matricula.ano_censo
'
,
'
census_year
'
)
.
field
(
'
localizacao.descricao
'
,
'
location_name
'
)
.
from
(
'
localizacao
'
)
.
from
(
'
matricula
'
)
.
where
(
'
matricula.localizacao_id=localizacao.id
'
)
.
where
(
'
matricula.tipo <= 3
'
)
.
where
(
`matricula.ano_censo IN (
${
schoolClassYearQry
}
)`
)
.
group
(
'
matricula.ano_censo
'
)
.
group
(
'
localizacao.descricao
'
)
.
order
(
'
ano_censo
'
)
.
order
(
'
localizacao.descricao
'
);
const
queryLabels
=
[
"
school
"
,
"
school_per_location
"
,
"
school_per_adm_dependency
"
,
"
enrollment
"
,
"
enrollment_per_adm_dep
"
,
"
enrollment_per_school_level
"
,
"
enrollment_per_location
"
];
const
querySet
=
[
totalSchoolsQry
,
schoolsPerLocationQry
,
schoolsPerAdmDependencyQry
,
enrollmentsQry
,
enrollmentsPerAdmDepQry
,
enrollmentsPerSchoolLevelQry
,
enrollmentsPerLocationQry
];
// wait until all queries finish or one of them fail
Promise
.
all
(
dbExecAll
(
querySet
)).
then
((
queryResults
)
=>
{
req
.
result
=
processResultSet
(
queryResults
,
queryLabels
);
...
...
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