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
d812b7cd
There was a problem fetching the pipeline summary.
Commit
d812b7cd
authored
7 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Add download route to /school
parent
a8a4c2d4
No related branches found
No related tags found
1 merge request
!116
Release v1.0.0
Pipeline
#
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/libs/jobs/download.js
+4
-3
4 additions, 3 deletions
src/libs/jobs/download.js
src/libs/routes/region.js
+7
-7
7 additions, 7 deletions
src/libs/routes/region.js
src/libs/routes/school.js
+9
-0
9 additions, 0 deletions
src/libs/routes/school.js
with
20 additions
and
10 deletions
src/libs/jobs/download.js
+
4
−
3
View file @
d812b7cd
...
...
@@ -14,15 +14,16 @@ module.exports = function(agenda) {
// Roda o COPY INTO
// Cria o registro no mongo
// Manda email notificando o usuário
let
path
=
'
/tmp/
'
+
table
+
Date
.
now
()
+
'
.csv
'
;
log
.
debug
(
sql
);
let
path
=
'
/tmp/
'
+
table
+
'
-
'
+
Date
.
now
()
+
'
.csv
'
;
let
query
=
`COPY
${
sql
}
INTO '
${
path
}
' USING DELIMITERS ';'`
;
execQuery
(
query
,
[]).
then
((
result
)
=>
{
// If we're here then everything is ok. Result is empty
let
file
=
{
name
:
table
,
path
path
,
table
:
table
,
query
:
sql
}
request
.
post
(
config
.
cdn
.
url
+
'
/api/v1/file
'
,
{
form
:
file
},
(
err
,
response
,
body
)
=>
{
if
(
err
)
{
...
...
This diff is collapsed.
Click to expand it.
src/libs/routes/region.js
+
7
−
7
View file @
d812b7cd
...
...
@@ -54,13 +54,13 @@ regionApp.get('/', rqf.parse(), (req, res, next) => {
next
();
},
rqf
.
build
(),
query
,
response
(
'
region
'
));
const
agenda
=
require
(
`
${
libs
}
/agenda`
);
//
const agenda = require(`${libs}/agenda`);
regionApp
.
get
(
'
/download
'
,
(
req
,
res
)
=>
{
req
.
sql
.
from
(
'
regiao
'
).
field
(
'
*
'
);
let
params
=
req
.
sql
;
agenda
.
now
(
'
download database
'
,
{
sql
:
req
.
sql
.
toString
(),
table
:
req
.
sql
.
tableFrom
});
res
.
json
({
msg
:
'
Wait for it...
'
});
});
//
regionApp.get('/download', (req, res) => {
//
req.sql.from('regiao').field('*');
//
let params = req.sql;
//
agenda.now('download database', {sql: req.sql.toString(), table: req.sql.tableFrom});
//
res.json({msg: 'Wait for it...'});
//
});
module
.
exports
=
regionApp
;
This diff is collapsed.
Click to expand it.
src/libs/routes/school.js
+
9
−
0
View file @
d812b7cd
...
...
@@ -14,6 +14,8 @@ const id2str = require(`${libs}/middlewares/id2str`);
const
ReqQueryFields
=
require
(
`
${
libs
}
/middlewares/reqQueryFields`
);
const
agenda
=
require
(
`
${
libs
}
/agenda`
);
let
rqf
=
new
ReqQueryFields
();
let
rqfCount
=
new
ReqQueryFields
();
...
...
@@ -872,4 +874,11 @@ schoolApp.get('/count', rqfCount.parse(), rqfCount.build(), (req, res, next) =>
next
();
},
query
,
id2str
.
transform
(),
response
(
'
school
'
));
schoolApp
.
get
(
'
/download
'
,
rqf
.
parse
(),
rqf
.
build
(),
(
req
,
res
,
next
)
=>
{
req
.
sql
.
from
(
'
escola
'
)
.
field
(
'
*
'
);
agenda
.
now
(
'
download database
'
,
{
sql
:
req
.
sql
.
toString
(),
table
:
req
.
sql
.
tableFrom
});
res
.
json
({
msg
:
'
Wait for download email
'
});
});
module
.
exports
=
schoolApp
;
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