Skip to content

Commit

Permalink
fix promise.all call
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Dec 4, 2023
1 parent 4d9019a commit 662f6b9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions store/queries.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ export async function insertMatchPromise(match, options) {
arr.push({ key, account_id: player.account_id });
});
});
await Promise.all(arr, (val) => clearCache(val));
await Promise.all(arr.map((val) => clearCache(val)));
}
async function decideCounts() {
// We only do this if fresh match
Expand Down Expand Up @@ -1049,16 +1049,15 @@ export async function insertMatchPromise(match, options) {
config.ENABLE_RANDOM_MMR_UPDATE
);
});
console.log(arr);
await Promise.all(arr, (p) =>
await Promise.all(arr.map((p) =>
queue.addJob(
'mmrQueue',
JSON.stringify({
match_id: match.match_id,
account_id: p.account_id,
})
)
);
));
}
async function decideProfile() {
// We only do this if fresh match
Expand Down
4 changes: 2 additions & 2 deletions svc/cosmetics.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ while (true) {
});
}

const promises = Object.keys(itemData.items_game.items).map((i) =>
const promiseFuncs = Object.keys(itemData.items_game.items).map((i) =>
() => processItem(i)
);
await eachLimit(promises, 10);
await eachLimit(promiseFuncs, 10);

console.timeEnd('doCosmetics');
await new Promise((resolve) => setTimeout(resolve, 12 * 60 * 60 * 1000));
Expand Down
4 changes: 2 additions & 2 deletions svc/fullhistory.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ function processFullHistory(job, cb) {
delete player.match_ids[matchId];
}
// make api_details requests for matches
const promises = Object.keys(player.match_ids).map((matchId) =>
const promiseFuncs = Object.keys(player.match_ids).map((matchId) =>
() => processMatch(matchId)
);
await eachLimit(promises, parallelism);
await eachLimit(promiseFuncs, parallelism);
await updatePlayer(player);
}
cb();
Expand Down

0 comments on commit 662f6b9

Please sign in to comment.