Merge pull request #22061 from overleaf/jpa-reduce-idle-time

[history-v1] back_fill_file_hash: reduce idle time between batches

GitOrigin-RevId: 9b24bb882b158f33915d2e0ab2f82273eac09739
This commit is contained in:
Jakob Ackermann
2024-11-22 09:05:55 +00:00
committed by Copybot
parent fb45c3c144
commit 69021ca4b0
3 changed files with 127 additions and 42 deletions
+8 -2
View File
@@ -253,8 +253,14 @@ function expressifyErrorHandler(fn) {
* Map values in `array` with the async function `fn`
*
* Limit the number of unresolved promises to `concurrency`.
* @template T
* @template V
* @param {number} concurrency
* @param {Array<T>} array
* @param {(arg: T) => Promise<V>} fn
* @return {Promise<Array<Awaited<V>>>}
*/
function promiseMapWithLimit(concurrency, array, fn) {
async function promiseMapWithLimit(concurrency, array, fn) {
const limit = pLimit(concurrency)
return Promise.all(array.map(x => limit(() => fn(x))))
return await Promise.all(array.map(x => limit(() => fn(x))))
}