From e45cc45f381da6129319c5eb80b898ffc2b75bf6 Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Thu, 10 Oct 2024 19:27:00 +0530 Subject: [PATCH] Check auction status only if deployments don't exist --- packages/backend/src/service.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index d9d3aa46..9f010bec 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -1,6 +1,6 @@ import assert from 'assert'; import debug from 'debug'; -import { DeepPartial, FindOptionsWhere, IsNull } from 'typeorm'; +import { DeepPartial, FindOptionsWhere, IsNull, Not } from 'typeorm'; import { Octokit, RequestError } from 'octokit'; import { OAuthApp } from '@octokit/oauth-app'; @@ -275,14 +275,15 @@ export class Service { * Calls the createDeploymentFromAuction method for deployments with completed auctions */ async checkAuctionStatus(): Promise { - const projects = await this.db.getProjects({ + const allProjects = await this.db.getProjects({ where: { - deployments: { - applicationDeploymentRequestId: IsNull() - } + auctionId: Not(IsNull()), }, + relations: ['deployments'], }); + const projects = allProjects.filter(project => project.deployments.length === 0); + const auctionIds = projects.map((project) => project.auctionId); const completedAuctionIds = await this.registry.getCompletedAuctionIds(auctionIds); @@ -298,6 +299,7 @@ export class Service { await this.db.updateProjectById(project.id!, { deployerLrn: deployerLrns }) + for (const deployer of deployerLrns) { await this.createDeploymentFromAuction(project, deployer); }