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
6694746e
There was a problem fetching the pipeline summary.
Commit
6694746e
authored
8 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Start updating enrollment routes
parent
9550c48f
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/libs/routes/enrollment.js
+13
-38
13 additions, 38 deletions
src/libs/routes/enrollment.js
with
13 additions
and
38 deletions
src/libs/routes/enrollment.js
+
13
−
38
View file @
6694746e
...
...
@@ -8,9 +8,11 @@ const log = require(`${libs}/log`)(module);
const
squel
=
require
(
'
squel
'
);
const
dbQuery
=
require
(
'
../db/query_exec
'
);
const
query
=
require
(
`
${
libs
}
/middlewares/query`
);
const
response
=
require
(
`
${
libs
}
/middlewares/response`
);
const
response
=
require
(
'
../
middlewares/response
'
);
const
dbQuery
=
require
(
'
../
db/query_exec
'
);
/**
* Complete range of the enrollments dataset
...
...
@@ -18,46 +20,19 @@ const response = require('../middlewares/response');
* Returns a tuple of start and ending years of the complete enrollments dataset.
*/
enrollmentApp
.
get
(
'
/year_range
'
,
(
req
,
res
,
next
)
=>
{
const
yearSql
=
'
SELECT MIN(t.ano_censo) AS start_year, MAX(t.ano_censo)
'
+
'
AS end_year FROM turmas AS t
'
;
dbQuery
(
yearSql
).
then
((
result
)
=>
{
const
record
=
result
[
'
0
'
];
log
.
debug
(
record
);
req
.
result
=
{
start_year
:
record
.
start_year
,
end_year
:
record
.
end_year
};
return
response
(
req
,
res
);
},
(
error
)
=>
{
log
.
error
(
`[
${
req
.
originalUrl
}
] SQL query error:
${
error
}
`
);
next
(
'
Internal error, request could not be satisfied at this moment. Please,
'
+
'
try again later
'
);
});
});
req
.
sql
=
squel
.
select
().
from
(
'
turmas
'
).
field
(
'
MIN(turmas.ano_censo)
'
,
'
start_year
'
).
field
(
'
MAX(turmas.ano_censo)
'
,
'
end_year
'
).
toParam
();
next
();
},
query
,
response
(
'
range
'
));
enrollmentApp
.
get
(
'
/education_level
'
,
(
req
,
res
,
next
)
=>
{
const
edLevelSql
=
'
SELECT pk_etapa_ensino_id AS id, desc_etapa AS
'
+
'
education_level FROM etapa_ensino
'
;
dbQuery
(
edLevelSql
).
then
((
result
)
=>
{
req
.
result
=
result
;
return
response
(
req
,
res
);
},
(
error
)
=>
{
log
.
error
(
`[
${
req
.
originalUrl
}
] SQL query error:
${
error
}
`
);
next
(
'
Internal error, request could not be satisfied at this moment. Please,
'
+
'
try again later
'
);
});
});
req
.
sql
=
squel
.
select
().
from
(
'
etapa_ensino
'
).
field
(
'
pk_etapa_ensino_id
'
,
'
id
'
).
field
(
'
desc_etapa
'
,
'
name
'
).
toParam
();
next
();
},
query
,
response
(
'
education_level
'
));
enrollmentApp
.
get
(
'
/data
'
,
(
req
,
res
,
next
)
=>
{
const
schoolClassSql
=
'
SELECT * FROM turmas
'
;
dbQuery
(
schoolClassSql
).
then
((
result
)
=>
{
req
.
result
=
result
;
return
response
(
req
,
res
);
},
(
error
)
=>
{
log
.
error
(
`[
${
req
.
originalUrl
}
] SQL query error:
${
error
}
`
);
next
(
'
Internal error, request could not be satisfied at this moment. Please,
'
+
'
try again later
'
);
});
});
req
.
sql
=
squel
.
select
().
from
(
'
turmas
'
).
toParam
();
next
();
},
query
,
response
(
'
data
'
));
enrollmentApp
.
use
(
'
/
'
,
(
req
,
res
,
next
)
=>
{
const
params
=
req
.
query
;
...
...
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