eslint, prettier fix

This commit is contained in:
Данил 2024-08-17 16:40:20 +03:00
parent bdc4450b72
commit 2679fa20d5
10 changed files with 284 additions and 208 deletions

View file

@ -10,20 +10,22 @@ const logger = require('../../logger/src/main.js');
*/
async function getDay(from_currency, conv_currency, date) {
if (!from_currency || !conv_currency) return new Error('fromCurrency and convCurrency are required');
if (!from_currency || !conv_currency)
return new Error('fromCurrency and convCurrency are required');
else if (!date) return new Error('date is required');
const data = await pool.query('SELECT from_currency, conv_currency, date, rate FROM currency ' +
'WHERE from_currency = $1 AND conv_currency = $2 AND date = $3', [
from_currency.toUpperCase(),
conv_currency.toUpperCase(),
date
]);
const data = await pool.query(
'SELECT from_currency, conv_currency, date, rate FROM currency ' +
'WHERE from_currency = $1 AND conv_currency = $2 AND date = $3',
[from_currency.toUpperCase(), conv_currency.toUpperCase(), date],
);
if (!data) return new Error('Missing data');
const set_date = data['rows'][0]['date'];
data['rows'][0]['date'] = new Date(set_date.setDate(set_date.getDate() + 1));
data['rows'][0]['date'] = new Date(
set_date.setDate(set_date.getDate() + 1),
);
logger.debug(data['rows'][0]);
@ -40,16 +42,21 @@ async function getDay(from_currency, conv_currency, date) {
*/
async function getPeriod(from_currency, conv_currency, start_date, end_date) {
if (!from_currency || !conv_currency) return new Error('from_currency and conv_currency are required');
else if(!start_date || !end_date) return new Error('start_date and end_date are required');
if (!from_currency || !conv_currency)
return new Error('from_currency and conv_currency are required');
else if (!start_date || !end_date)
return new Error('start_date and end_date are required');
const data = await pool.query('SELECT * FROM currency WHERE ' +
'(date BETWEEN $3 AND $4) AND from_currency = $1 AND conv_currency = $2 ORDER BY date', [
const data = await pool.query(
'SELECT * FROM currency WHERE ' +
'(date BETWEEN $3 AND $4) AND from_currency = $1 AND conv_currency = $2 ORDER BY date',
[
from_currency.toUpperCase(),
conv_currency.toUpperCase(),
start_date,
end_date
]);
end_date,
],
);
if (!data) return new Error('Missing data');
@ -63,4 +70,4 @@ async function getPeriod(from_currency, conv_currency, start_date, end_date) {
return data['rows'];
}
module.exports = { getDay, getPeriod };
module.exports = { getDay, getPeriod };

View file

@ -1,13 +1,12 @@
const pg = require("pg");
const config = require("../../config/src/main.js")();
const pg = require('pg');
const config = require('../../config/src/main.js')();
const pool = new pg.Pool({
user: config['database']['user'],
user: config['database']['user'],
password: config['database']['password'],
host: config['database']['host'],
port: config['database']['port'],
database: config['database']['name']
database: config['database']['name'],
});
module.exports = pool;
module.exports = pool;