Skip to content

Commit 2e038bd

Browse files
author
tombertrand
committed
Slow down API request to CG for market price
1 parent dd43503 commit 2e038bd

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

server/cron/coingeckoStats.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ const getMarketStats = async fiats => {
114114
};
115115

116116
nodeCache.set(`${COINGECKO_MARKET_STATS}-${fiat}`, marketStats);
117+
118+
await sleep(20000);
117119
}
118120
} catch (err) {
119121
// rate limited
@@ -276,15 +278,15 @@ cron.schedule("0 1 * * *", async () => {
276278
getMarketCapStats();
277279
});
278280

279-
// Every 30 seconds
280-
cron.schedule("*/30 * * * * *", async () => {
281+
// Every 2 minute
282+
cron.schedule("*/2 * * * *", async () => {
281283
getPriceStats(defaultFiats);
282284
getMarketStats(defaultFiats);
283285
});
284286

285-
// https://crontab.guru/#*/2_*_*_*_*
286-
// At every 2nd minute.
287-
cron.schedule("*/2 * * * *", async () => {
287+
// https://crontab.guru/#*/10_*_*_*_*
288+
// At every 10nd minute.
289+
cron.schedule("*/10 * * * *", async () => {
288290
getPriceStats(secondaryFiats);
289291
getMarketStats(secondaryFiats);
290292
});

0 commit comments

Comments
 (0)