mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 20:51:25 +03:00
Добавил дебаг лог
This commit is contained in:
parent
1b785f5acc
commit
98cb0aaad9
2 changed files with 12 additions and 3 deletions
|
@ -2,6 +2,7 @@ const ChartJSImage = require('chart.js-image');
|
||||||
const pool = require('../database/postgresql.js');
|
const pool = require('../database/postgresql.js');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
|
const logger = require('../logger/main.js')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Graph generation
|
* Graph generation
|
||||||
|
@ -54,8 +55,8 @@ async function gen_chart(from_currency, conv_currency, start_date, end_date) {
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
label: 'rate',
|
label: 'rate',
|
||||||
borderColor: rate[rate.length-2] < rate[rate.length-1] ? 'rgb(24, 218, 39)' : 'rgb(243, 85, 50)',
|
borderColor: rate[0] < rate[rate.length-1] ? 'rgb(24, 218, 39)' : 'rgb(243, 85, 50)',
|
||||||
backgroundColor: rate[rate.length-2] < rate[rate.length-1] ? 'rgb(36, 175, 47)' : 'rgb(218, 56, 24)',
|
backgroundColor: rate[0] < rate[rate.length-1] ? 'rgb(36, 175, 47)' : 'rgb(218, 56, 24)',
|
||||||
data: rate,
|
data: rate,
|
||||||
borderWidth: 2,
|
borderWidth: 2,
|
||||||
},
|
},
|
||||||
|
@ -82,6 +83,8 @@ async function gen_chart(from_currency, conv_currency, start_date, end_date) {
|
||||||
},
|
},
|
||||||
}).width(1000).height(1000);
|
}).width(1000).height(1000);
|
||||||
|
|
||||||
|
logger.debug(chart.toURL());
|
||||||
|
|
||||||
return chart.toURL();
|
return chart.toURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,6 +98,8 @@ function save_chart(url, filename) {
|
||||||
if (!fs.existsSync('../charts')) fs.mkdirSync('../charts');
|
if (!fs.existsSync('../charts')) fs.mkdirSync('../charts');
|
||||||
if (!url.startsWith('https://')) throw new Error('The passed parameter is not a URL');
|
if (!url.startsWith('https://')) throw new Error('The passed parameter is not a URL');
|
||||||
|
|
||||||
|
logger.info(`The schedule has been saved. The path of the graph 'chart/${filename}'`);
|
||||||
|
|
||||||
request(url).pipe(fs.createWriteStream(`../charts/${filename}`));
|
request(url).pipe(fs.createWriteStream(`../charts/${filename}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const pool = require('./postgresql.js');
|
const pool = require('./postgresql.js');
|
||||||
|
const logger = require('../logger/main.js');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getting the currency exchange rate for a specific day
|
* Getting the currency exchange rate for a specific day
|
||||||
|
@ -25,6 +25,8 @@ async function getDay(from_currency, conv_currency, date) {
|
||||||
let set_date = data['rows'][0]['date']
|
let set_date = data['rows'][0]['date']
|
||||||
set_date = new Date(set_date.setDate(set_date.getDate() + 1));
|
set_date = new Date(set_date.setDate(set_date.getDate() + 1));
|
||||||
|
|
||||||
|
logger.debug(data['rows'][0])
|
||||||
|
|
||||||
return data['rows'][0];
|
return data['rows'][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +58,8 @@ async function getPeriod(from_currency, conv_currency, start_date, end_date) {
|
||||||
date = new Date(date.setDate(date.getDate() + 1));
|
date = new Date(date.setDate(date.getDate() + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.debug(data['rows'])
|
||||||
|
|
||||||
return data['rows'];
|
return data['rows'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue