mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 20:51:25 +03:00
теперь можно посмотреть данные за опр. пероид
This commit is contained in:
parent
33808437e9
commit
4da4bbda91
1 changed files with 15 additions and 1 deletions
16
main.js
16
main.js
|
@ -26,7 +26,7 @@ fastify.get('/api/getRate/', async function (req, reply) {
|
||||||
'periodStart parameter is required'
|
'periodStart parameter is required'
|
||||||
);
|
);
|
||||||
|
|
||||||
const data = await pool.query('SELECT * FROM currency WHERE from_currency = $1 AND date = $2', [
|
let data = await pool.query('SELECT * FROM currency WHERE from_currency = $1 AND date = $2', [
|
||||||
req['query']['codeCurrency'],
|
req['query']['codeCurrency'],
|
||||||
req['query']['periodStart'],
|
req['query']['periodStart'],
|
||||||
]).then(response('error', 500, 'Internal Server Error'));
|
]).then(response('error', 500, 'Internal Server Error'));
|
||||||
|
@ -37,6 +37,20 @@ fastify.get('/api/getRate/', async function (req, reply) {
|
||||||
'There is no data for this time'
|
'There is no data for this time'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (req['query']?.['periodEnd']) {
|
||||||
|
let data = await pool.query('SELECT * FROM currency WHERE (date BETWEEN $2 AND $3) AND from_currency = $1', [
|
||||||
|
req['query']['codeCurrency'],
|
||||||
|
req['query']['periodStart'],
|
||||||
|
req['query']['periodEnd'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
console.log(data)
|
||||||
|
|
||||||
|
return data['rows'];
|
||||||
|
} else {
|
||||||
|
return response('error', 204, 'There is no data for this time')
|
||||||
|
}
|
||||||
|
|
||||||
return data['rows'];
|
return data['rows'];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue