исправил ошибку при которой не все пары валют добавлялсь в бд

This commit is contained in:
Данил 2024-02-18 14:23:12 +03:00
parent 874c7ac1f1
commit 394062ab72

View file

@ -2,7 +2,6 @@ const pool = require("../postgresql.js");
const yaml = require("yaml") const yaml = require("yaml")
const fs = require("fs"); const fs = require("fs");
const axios = require("axios"); const axios = require("axios");
const {AxiosProxyConfig} = require("axios");
const config = yaml.parse(fs.readFileSync("./config.yaml", "utf-8")); const config = yaml.parse(fs.readFileSync("./config.yaml", "utf-8"));
async function saveRate() { async function saveRate() {
@ -34,9 +33,10 @@ async function saveRate() {
const point = data['to'][0]['mid'].toString().indexOf('.') + 4; const point = data['to'][0]['mid'].toString().indexOf('.') + 4;
pool.query('SELECT * FROM currency WHERE from_currency = $1 AND date = $2', pool.query('SELECT * FROM currency WHERE from_currency = $1 AND conv_currency = $2 AND date = $3',
[ [
value, value,
pair,
new Date(data['timestamp']).toLocaleDateString() new Date(data['timestamp']).toLocaleDateString()
] ]
).then(async (db) => { ).then(async (db) => {