Skip to content

Commit

Permalink
Promise.all -> Promise.allSettled
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaumaus committed Dec 19, 2024
1 parent 24ebe6f commit d6b016b
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions backend/apps/cloud/src/analytics/analytics.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ export class AnalyticsController {
})

try {
await Promise.all(validationPromises)
await Promise.allSettled(validationPromises)
} catch {
// eslint-disable-next-line no-empty
}
Expand Down Expand Up @@ -903,16 +903,31 @@ export class AnalyticsController {
} = data
const pidsArray = getPIDsArray(pids, pid)

const validPids = []

const validationPromises = _map(pidsArray, async currentPID => {
await this.analyticsService.checkProjectAccess(currentPID, uid)

await this.analyticsService.checkBillingAccess(currentPID)

validPids.push(currentPID)
})

await Promise.all(validationPromises)
try {
await Promise.allSettled(validationPromises)
} catch {
// eslint-disable-next-line no-empty
}

if (_isEmpty(validPids)) {
throw new HttpException(
'The data could not be loaded for the selected projects. It is possible that the projects are not accessible to you or the account owner has been suspended.',
HttpStatus.PAYMENT_REQUIRED,
)
}

return this.analyticsService.getCaptchaSummary(
pidsArray,
validPids,
period,
from,
to,
Expand Down Expand Up @@ -1017,7 +1032,7 @@ export class AnalyticsController {
})

try {
await Promise.all(validationPromises)
await Promise.allSettled(validationPromises)
// eslint-disable-next-line no-empty
} catch {}

Expand Down

0 comments on commit d6b016b

Please sign in to comment.