From 9f6aa43586ef6ad12eba34586844e64ce34b9dbc Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Wed, 16 Oct 2024 17:19:53 +0530 Subject: [PATCH] Update code to handle re-deployments on pushing --- packages/backend/src/registry.ts | 5 ++--- packages/backend/src/service.ts | 8 +++----- packages/backend/src/types.ts | 20 -------------------- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/packages/backend/src/registry.ts b/packages/backend/src/registry.ts index d678d131..206bf6b4 100644 --- a/packages/backend/src/registry.ts +++ b/packages/backend/src/registry.ts @@ -16,7 +16,6 @@ import { } from './entity/Deployment'; import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionData } from './types'; import { getConfig, getRepoDetails, sleep } from './utils'; -import { Auction } from '@cerc-io/registry-sdk/dist/proto/cerc/auction/v1/auction'; const log = debug('snowball:registry'); @@ -428,8 +427,8 @@ export class Registry { const auctions = await this.registry.getAuctionsByIds(validAuctionIds); const completedAuctions = auctions - .filter((auction: Auction) => auction.status === 'completed') - .map((auction: Auction) => auction.id); + .filter((auction: { id: string, status: string }) => auction.status === 'completed') + .map((auction: { id: string, status: string }) => auction.id); return completedAuctions; } diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 5ec8d2fe..a1b2a90d 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -319,7 +319,7 @@ export class Service { if (completedAuctionIds) { const projectsToBedeployed = projects.filter((project) => - completedAuctionIds.includes(project.auctionId!) + completedAuctionIds.includes(project.auctionId!) && project.deployerLrns !== null ); for (const project of projectsToBedeployed) { @@ -878,6 +878,7 @@ export class Service { await this.updateProject(project.id, { auctionId: applicationDeploymentAuctionId }) } else { await this.createDeployment(user.id, octokit, deploymentData, lrn!); + await this.updateProject(project.id, { deployerLrns: [lrn!] }) } await this.createRepoHook(octokit, project); @@ -948,9 +949,7 @@ export class Service { }); const deployers = project.deployerLrns; - if (!deployers) { - return; - } + if (!deployers) return; for (const deployer of deployers) { // Create deployment with branch and latest commit in GitHub data @@ -970,7 +969,6 @@ export class Service { ); } } - } async updateProject( diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts index 4b0b02f9..2bb58104 100644 --- a/packages/backend/src/types.ts +++ b/packages/backend/src/types.ts @@ -72,26 +72,6 @@ export interface AddProjectFromTemplateInput { isPrivate: boolean; } -export interface Auction { - id: string; - kind: string; - status: string; - ownerAddress: string; - createTime: Date; - commitsEndTime: Date; - revealsEndTime: Date; - commitFee: string; - revealFee: string; - minimumBid?: string; - winnerAddresses: string[]; - winnerBids?: string[]; - winnerPrice?: string; - maxPrice?: string; - numProviders: number; - fundsReleased: boolean; - bids: string[]; -} - export interface AuctionData { maxPrice: string, numProviders: number,