Skip to content
Snippets Groups Projects
Commit 4a54e770 authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Add CSV and XML response to /data and /year_range

parent 42709f1b
No related branches found
No related tags found
1 merge request!5Implement basic queries for enrollments
Pipeline #
......@@ -23,22 +23,36 @@ router.get('/', function (req, res) {
router.get('/year_range', function(req, res) {
var yearSql = "SELECT MIN(t.ano_censo) AS start_year, MAX(t.ano_censo) AS end_year FROM turmas AS t";
conn.query(yearSql, true).then(function(result) {
if (req.query.format === 'csv') {
res.csv(result.data);
} else if (req.query.format === 'xml') {
res.send(xml("result", JSON.stringify({year_range: result.data})))
}
else {
res.json({
result: result.data
})
});
}
});
})
router.get('/data', function(req, res) {
console.log(req.query)
console.log(req.query.met)
console.log(req.query.dim)
log.debug(req.query)
log.debug(req.query.met)
log.debug(req.query.dim)
conn.query(
'SELECT * FROM turmas'
).then(function(result) {
if (req.query.format === 'csv') {
res.csv(result.data);
} else if (req.query.format === 'xml') {
res.send(xml("result", JSON.stringify({data: result.data})))
}
else {
res.json({
result: result
})
result: result.data
});
}
})
})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment