From 686cc368496e4fad5194d03c848fd07d9f4bb480 Mon Sep 17 00:00:00 2001 From: Cassidy Schaufele Date: Tue, 19 Jul 2022 08:40:12 -0600 Subject: [PATCH] Promise.all()ify scheduled deploy routine --- api/controllers/v1/scheduled/index.ts | 7 ++++--- api/controllers/v1/scheduled/utils/index.ts | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/api/controllers/v1/scheduled/index.ts b/api/controllers/v1/scheduled/index.ts index 67c362ca7..631efc3cd 100644 --- a/api/controllers/v1/scheduled/index.ts +++ b/api/controllers/v1/scheduled/index.ts @@ -3,9 +3,10 @@ import { options as docsLandingOptions } from './repos/docs-landing'; export const DeployDocsLanding = async () => { const { branches, repoName, repoOwner } = docsLandingOptions; - for (const branch of branches) { - await DeployRepo(repoOwner, repoName, branch) - } + Promise.all(branches.map(branch => { + return DeployRepo(repoOwner, repoName, branch) + }) + ) return { statusCode: 200, diff --git a/api/controllers/v1/scheduled/utils/index.ts b/api/controllers/v1/scheduled/utils/index.ts index de040e261..9e4d8cbeb 100644 --- a/api/controllers/v1/scheduled/utils/index.ts +++ b/api/controllers/v1/scheduled/utils/index.ts @@ -139,9 +139,9 @@ const getDeployableJobs = async (repoOwner:string , repoName:string , branchName async function deployRepo(deployable: Array, logger: ILogger, jobRepository: JobRepository, jobQueueUrl) { try { - await jobRepository.insertBulkJobs(deployable, jobQueueUrl); + return jobRepository.insertBulkJobs(deployable, jobQueueUrl); } catch (err) { - logger.error('deployRepo', err);x + logger.error('deployRepo', err); } } @@ -155,6 +155,6 @@ export const DeployRepo = async (repoOwner, repoName, branchName): Promise const deployable = await getDeployableJobs(repoOwner, repoName, branchName, branchRepository); if (deployable.length > 0) { - await deployRepo(deployable, consoleLogger, jobRepository, c.get('jobsQueueUrl')); + return deployRepo(deployable, consoleLogger, jobRepository, c.get('jobsQueueUrl')); } }; \ No newline at end of file