Skip to content

Commit e454b20

Browse files
committed
ensure the list of scores exists
1 parent a1c98da commit e454b20

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

server/api/richList.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ const getRichListPage = async (page = 1) =>
2424
"WITHSCORES",
2525
(err, list) => {
2626
const data = [];
27-
list.forEach(value => {
28-
if (value.startsWith("nano_")) {
29-
data.push({ account: value });
30-
} else {
31-
data[data.length - 1].balance = parseFloat(value);
32-
}
33-
});
27+
list &&
28+
list.length &&
29+
list.forEach(value => {
30+
if (value.startsWith("nano_")) {
31+
data.push({ account: value });
32+
} else {
33+
data[data.length - 1].balance = parseFloat(value);
34+
}
35+
});
3436

3537
if (err) Sentry.captureException(err);
3638
resolve({ data, meta: { total, perPage: PER_PAGE, offset } });

server/cron/coingeckoStats.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const getPriceStats = async fiats => {
4646
bitcoin: json.bitcoin,
4747
nano: json.nano,
4848
});
49+
50+
await sleep(25_000);
4951
}
5052
} catch (err) {
5153
console.log("Error", err);
@@ -88,7 +90,7 @@ const getMarketStats = async fiats => {
8890

8991
nodeCache.set(`${COINGECKO_MARKET_STATS}-${fiat}`, marketStats);
9092

91-
await sleep(20000);
93+
await sleep(20_000);
9294
}
9395
} catch (err) {
9496
// rate limited
@@ -213,9 +215,9 @@ const getMarketCapStats = async () => {
213215

214216
// CoinGecko rate limit is 10 calls per seconds
215217
if (i && !(i % 10)) {
216-
await sleep(25000);
218+
await sleep(25_000);
217219
} else {
218-
await sleep(process.env.NODE_ENV === "production" ? 15000 : 150);
220+
await sleep(process.env.NODE_ENV === "production" ? 15_000 : 150);
219221
}
220222
}
221223

@@ -225,7 +227,7 @@ const getMarketCapStats = async () => {
225227
});
226228
} else {
227229
console.log(`Failed to get top ${top} cryptocurrencies`, cryptocurrencies);
228-
await sleep(10000);
230+
await sleep(10_000);
229231

230232
getMarketCapStats();
231233
return;

0 commit comments

Comments
 (0)