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
3c9b05a1
There was a problem fetching the pipeline summary.
Commit
3c9b05a1
authored
8 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Start change in enrollment route to new db schema
parent
56abd94e
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/enrollment.js
+42
-59
42 additions, 59 deletions
src/libs/routes/enrollment.js
with
42 additions
and
59 deletions
src/libs/routes/enrollment.js
+
42
−
59
View file @
3c9b05a1
...
...
@@ -19,16 +19,15 @@ let rqf = new ReqQueryFields();
// Complete range of the enrollments dataset.
// Returns a tuple of start and ending years of the complete enrollments dataset.
enrollmentApp
.
get
(
'
/year_range
'
,
(
req
,
res
,
next
)
=>
{
req
.
sql
.
from
(
'
turma
'
)
.
field
(
'
MIN(turma.ano_censo)
'
,
'
start_year
'
)
.
field
(
'
MAX(turma.ano_censo)
'
,
'
end_year
'
);
req
.
sql
.
from
(
'
matricula
'
)
.
field
(
'
MIN(matricula.ano_censo)
'
,
'
start_year
'
)
.
field
(
'
MAX(matricula.ano_censo)
'
,
'
end_year
'
);
next
();
},
query
,
response
(
'
range
'
));
enrollmentApp
.
get
(
'
/location
'
,
(
req
,
res
,
next
)
=>
{
req
.
sql
=
squel
.
select
()
.
field
(
'
pk_localizacao_id
'
,
'
id
'
)
.
field
(
'
id
'
)
.
field
(
'
descricao
'
,
'
name
'
)
.
from
(
'
localizacao
'
);
next
();
...
...
@@ -37,18 +36,16 @@ enrollmentApp.get('/location', (req, res, next) => {
// Returns all educational levels avaible
enrollmentApp
.
get
(
'
/education_level
'
,
(
req
,
res
,
next
)
=>
{
req
.
sql
.
from
(
'
etapa_ensino
'
)
.
field
(
'
pk_etapa_ensino_
id
'
,
'
id
'
)
.
field
(
'
id
'
,
'
id
'
)
.
field
(
'
desc_etapa
'
,
'
name
'
);
next
();
},
query
,
response
(
'
education_level
'
));
// Returns all adm dependencies
enrollmentApp
.
get
(
'
/adm_dependency
'
,
(
req
,
res
,
next
)
=>
{
req
.
sql
.
from
(
'
dependencia_adm
'
)
.
field
(
'
pk_dependencia_adm_
id
'
,
'
id
'
)
.
field
(
'
id
'
,
'
id
'
)
.
field
(
'
nome
'
,
'
name
'
);
next
();
},
query
,
response
(
'
adm_dependency
'
));
...
...
@@ -68,12 +65,12 @@ rqf.addField({
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
pk_dependencia_adm_
id
'
field
:
'
id
'
},
join
:
{
primary
:
'
pk_dependencia_adm_
id
'
,
foreign
:
'
fk_
dependencia_adm_id
'
,
foreignTable
:
'
turm
a
'
primary
:
'
id
'
,
foreign
:
'
dependencia_adm_id
'
,
foreignTable
:
'
matricul
a
'
}
}).
addValue
({
name
:
'
education_level
'
,
...
...
@@ -83,12 +80,12 @@ rqf.addField({
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
pk_etapa_ensino_
id
'
field
:
'
id
'
},
join
:
{
primary
:
'
pk_etapa_ensino_
id
'
,
foreign
:
'
fk_
etapa_ensino_id
'
,
foreignTable
:
'
turm
a
'
primary
:
'
id
'
,
foreign
:
'
etapa_ensino_id
'
,
foreignTable
:
'
matricul
a
'
}
}).
addValue
({
name
:
'
region
'
,
...
...
@@ -98,12 +95,12 @@ rqf.addField({
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
pk_regiao_
id
'
field
:
'
id
'
},
join
:
{
primary
:
'
pk_regiao_
id
'
,
foreign
:
'
fk
_regiao
_id
'
,
foreignTable
:
'
turm
a
'
primary
:
'
id
'
,
foreign
:
'
cod
_regiao
'
,
foreignTable
:
'
matricul
a
'
}
}).
addValue
({
name
:
'
state
'
,
...
...
@@ -113,12 +110,12 @@ rqf.addField({
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
pk_estado_
id
'
field
:
'
id
'
},
join
:
{
primary
:
'
pk_estado_
id
'
,
foreign
:
'
fk
_estado_id
'
,
foreignTable
:
'
turm
a
'
primary
:
'
id
'
,
foreign
:
'
escola
_estado_id
'
,
foreignTable
:
'
matricul
a
'
}
}).
addValue
({
name
:
'
city
'
,
...
...
@@ -128,12 +125,12 @@ rqf.addField({
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
pk_cod_ibge
'
field
:
'
id
'
},
join
:
{
primary
:
'
pk_cod_ibge
'
,
foreign
:
'
fk
_municipio_id
'
,
foreignTable
:
'
turm
a
'
primary
:
'
id
'
,
foreign
:
'
escola
_municipio_id
'
,
foreignTable
:
'
matricul
a
'
}
}).
addValue
({
name
:
'
school
'
,
...
...
@@ -143,12 +140,12 @@ rqf.addField({
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
cod_entidade
'
field
:
'
id
'
},
join
:
{
primary
:
'
cod_entidade
'
,
foreign
:
'
cod_entidade
'
,
foreignTable
:
'
turm
a
'
primary
:
'
id
'
,
foreign
:
'
escola_id
'
,
foreignTable
:
'
matricul
a
'
}
}).
addValue
({
name
:
'
location
'
,
...
...
@@ -158,31 +155,16 @@ rqf.addField({
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
pk_localizacao_id
'
},
join
:
{
primary
:
'
pk_localizacao_id
'
,
foreign
:
'
fk_localizacao_id
'
,
foreignTable
:
'
turma
'
}
}).
addValue
({
name
:
'
city
'
,
table
:
'
municipio
'
,
tableField
:
'
nome
'
,
resultField
:
'
city_name
'
,
where
:
{
relation
:
'
=
'
,
type
:
'
integer
'
,
field
:
'
pk_cod_ibge
'
field
:
'
id
'
},
join
:
{
primary
:
'
pk_cod_ibge
'
,
foreign
:
'
fk_municipi
o_id
'
,
foreignTable
:
'
turm
a
'
primary
:
'
id
'
,
foreign
:
'
localizaca
o_id
'
,
foreignTable
:
'
matricul
a
'
}
}).
addValue
({
name
:
'
min_year
'
,
table
:
'
turm
a
'
,
table
:
'
matricul
a
'
,
tableField
:
'
ano_censo
'
,
resultField
:
'
year
'
,
where
:
{
...
...
@@ -192,7 +174,7 @@ rqf.addField({
}
}).
addValue
({
name
:
'
max_year
'
,
table
:
'
turm
a
'
,
table
:
'
matricul
a
'
,
tableField
:
'
ano_censo
'
,
resultField
:
'
year
'
,
where
:
{
...
...
@@ -204,12 +186,13 @@ rqf.addField({
enrollmentApp
.
get
(
'
/
'
,
rqf
.
parse
(),
rqf
.
build
(),
(
req
,
res
,
next
)
=>
{
log
.
debug
(
req
.
sql
.
toParam
());
req
.
sql
.
field
(
'
COALESCE(
SUM(num_
matricula
s
), 0)
'
,
'
total
'
)
req
.
sql
.
field
(
'
COALESCE(
COUNT(
matricula
.id
), 0)
'
,
'
total
'
)
.
field
(
"
'Brasil'
"
,
'
name
'
)
.
field
(
'
turma.ano_censo
'
,
'
year
'
)
.
from
(
'
turma
'
)
.
group
(
'
turma.ano_censo
'
)
.
order
(
'
turma.ano_censo
'
);
.
field
(
'
matricula.ano_censo
'
,
'
year
'
)
.
from
(
'
matricula
'
)
.
group
(
'
matricula.ano_censo
'
)
.
order
(
'
matricula.ano_censo
'
)
.
where
(
'
matricula.tipo=0 OR matricula.tipo=1 OR matricula.tipo=2 OR matricula.tipo=3
'
);
next
();
},
query
,
response
(
'
enrollment
'
));
...
...
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