Skip to content

Commit 6769013

Browse files
committed
perf: better loop
1 parent 9f95a24 commit 6769013

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/helpers/votesVpValue.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ async function refreshVotesVpValues(data: Datum[]) {
5656

5757
export default async function run() {
5858
while (true) {
59-
while (true) {
60-
const votes = await getVotes();
61-
62-
if (votes.length === 0) break;
59+
const votes = await getVotes();
6360

61+
if (votes.length) {
6462
await refreshVotesVpValues(votes);
63+
}
6564

66-
if (votes.length < BATCH_SIZE) break;
65+
if (votes.length < BATCH_SIZE) {
66+
await snapshot.utils.sleep(REFRESH_INTERVAL);
6767
}
68-
await snapshot.utils.sleep(REFRESH_INTERVAL);
6968
}
7069
}

0 commit comments

Comments
 (0)