Compare commits
No commits in common. "1c348566f0567cea318ec85d6c7f084cc19640ef" and "85c8e69ee42ade844de4ed0baee6117a3f5ff9a4" have entirely different histories.
1c348566f0
...
85c8e69ee4
3 changed files with 0 additions and 28 deletions
26
main.js
26
main.js
|
@ -10,9 +10,6 @@ const config = require('./utils/load_config.js')();
|
|||
const services = [];
|
||||
const servicesDir = path.join(__dirname, 'services');
|
||||
|
||||
let fiatFetched = false;
|
||||
let cryptoFetched = false;
|
||||
|
||||
async function main() {
|
||||
if (!config['schedule'])
|
||||
throw new Error('The crontab schedule is not set.');
|
||||
|
@ -37,9 +34,6 @@ async function main() {
|
|||
schedule.scheduleJob(config['schedule'], async () => {
|
||||
console.log('Running scheduled task at:', new Date());
|
||||
|
||||
fiatFetched = false;
|
||||
cryptoFetched = false;
|
||||
|
||||
for (const srv of services) {
|
||||
const results = await srv.parseCurrencies();
|
||||
|
||||
|
@ -48,16 +42,6 @@ async function main() {
|
|||
|
||||
for (const result of results) {
|
||||
try {
|
||||
if (srv.info.type === 'fiat' && fiatFetched) {
|
||||
console.log('Skipping fiat currency collection as data has already been fetched.');
|
||||
continue;
|
||||
}
|
||||
|
||||
if (srv.info.type === 'crypto' && cryptoFetched) {
|
||||
console.log('Skipping crypto currency collection as data has already been fetched.');
|
||||
continue;
|
||||
}
|
||||
|
||||
const currency = await validateCurrency(result);
|
||||
|
||||
await pool.query(
|
||||
|
@ -75,16 +59,6 @@ async function main() {
|
|||
console.error(validationError);
|
||||
}
|
||||
}
|
||||
|
||||
if (srv.info.type === 'crypto') {
|
||||
cryptoFetched = true;
|
||||
console.log('Crypto currency data fetched successfully.');
|
||||
}
|
||||
|
||||
if (srv.info.type === 'fiat') {
|
||||
fiatFetched = true;
|
||||
console.log('Fiat currency data fetched successfully.');
|
||||
}
|
||||
} else {
|
||||
console.error("Data not received for writing to the database.");
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ const { truncate_number } = require('../utils/truncate_number.js');
|
|||
module.exports = {
|
||||
info: {
|
||||
name: 'CoinMarketCap',
|
||||
type: 'crypto'
|
||||
},
|
||||
parseCurrencies: async () => {
|
||||
const promises = config['currency']['crypto'].map(fromCurrency => {
|
||||
|
|
|
@ -5,7 +5,6 @@ const { truncate_number } = require('../utils/truncate_number.js');
|
|||
module.exports = {
|
||||
info: {
|
||||
name: 'DuckDuckGo',
|
||||
type: 'fiat'
|
||||
},
|
||||
parseCurrencies: async () => {
|
||||
const promises = config['currency']['fiat'].map(fromCurrency => {
|
||||
|
|
Loading…
Add table
Reference in a new issue