diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 3fd91bd9..5ec8d2fe 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -169,29 +169,32 @@ export class Service { const deployments = await this.db.getDeployments({ where: records.map((record) => ({ applicationRecordId: record.attributes.application, + // Only for the specific deployer + deployerLrn: record.attributes.deployer })), order: { createdAt: 'DESC', }, }); - // Get project IDs of deployments that are in production environment - const productionDeploymentProjectIds = deployments.reduce( - (acc, deployment): Set => { - if (deployment.environment === Environment.Production) { - acc.add(deployment.projectId); + // Get deployment IDs of deployments that are in production environment + const productionDeploymentIds: string[] = []; + deployments.forEach(deployment => { + if (deployment.environment === Environment.Production) { + if (!productionDeploymentIds.includes(deployment.id)) { + productionDeploymentIds.push(deployment.id); } - - return acc; - }, - new Set(), - ); + } + }); // Set old deployments isCurrent to false - await this.db.updateDeploymentsByProjectIds( - Array.from(productionDeploymentProjectIds), - { isCurrent: false }, - ); + // TODO: Only set isCurrent to false for the deployment for that specific deployer + for (const deploymentId of productionDeploymentIds) { + await this.db.updateDeployment( + { id: deploymentId }, + { isCurrent: false } + ); + } const recordToDeploymentsMap = deployments.reduce( (acc: { [key: string]: Deployment }, deployment) => { @@ -303,7 +306,13 @@ export class Service { }); // Should only check on the first deployment - const projects = allProjects.filter(project => project.deployments.length === 0); + const projects = allProjects.filter(project => { + if (project.deletedAt !== null) return false; + + const deletedDeployments = project.deployments.filter(deployment => deployment.deletedAt !== null).length; + + return project.deployments.length === 0 && deletedDeployments === 0; + }); const auctionIds = projects.map((project) => project.auctionId); const completedAuctionIds = await this.laconicRegistry.getCompletedAuctionIds(auctionIds); @@ -314,14 +323,16 @@ export class Service { ); for (const project of projectsToBedeployed) { - const deployerLrns = await this.laconicRegistry.getAuctionWinningDeployers(project!.auctionId!); + log(`Auction ${project!.auctionId} completed`); + const deployerLrns = await this.laconicRegistry.getAuctionWinningDeployers(project!.auctionId!); // Update project with deployer LRNs await this.db.updateProjectById(project.id!, { deployerLrns }); for (const deployer of deployerLrns) { + log(`Creating deployment for deployer LRN ${deployer}`); await this.createDeploymentFromAuction(project, deployer); } } @@ -838,6 +849,7 @@ export class Service { } const project = await this.db.addProject(user, organization.id, data); + log(`Project created ${project.id}`); const octokit = await this.getOctokit(user.id); const [owner, repo] = project.repository.split('/'); @@ -870,8 +882,6 @@ export class Service { await this.createRepoHook(octokit, project); - console.log('projectid is', project.id); - return project; } diff --git a/packages/backend/src/types.ts b/packages/backend/src/types.ts index 3f387d5d..4b0b02f9 100644 --- a/packages/backend/src/types.ts +++ b/packages/backend/src/types.ts @@ -29,6 +29,8 @@ export interface GitPushEventPayload { export interface AppDeploymentRecordAttributes { application: string; + auction: string; + deployer: string; dns: string; meta: string; name: string; diff --git a/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx b/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx index 57f5b855..2d36cdbe 100644 --- a/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx +++ b/packages/frontend/src/components/projects/project/deployments/DeploymentDetailsCard.tsx @@ -83,7 +83,7 @@ const DeploymentDetailsCard = ({ return (
-
+
{/* DEPLOYMENT URL */} {deployment.url && ( @@ -96,7 +96,12 @@ const DeploymentDetailsCard = ({ )} - + {deployment.deployerLrn && ( + + Deployer LRN: {deployment.deployerLrn} + + )} + {deployment.environment === Environment.Production ? `Production ${deployment.isCurrent ? '(Current)' : ''}` : 'Preview'} diff --git a/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx b/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx index 2ef7f5e3..518d1800 100644 --- a/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx +++ b/packages/frontend/src/components/projects/project/overview/Activity/AuctionCard.tsx @@ -28,7 +28,8 @@ export const AuctionCard = ({ project }: { project: Project }) => { const result = await client.getAuctionData(project.auctionId); setAuctionStatus(result.status); setAuctionDetails(result); - }, [client, project.auctionId]); + setDeployerLrns(project.deployerLrns); + }, [client, project.auctionId, project.deployerLrns]); useEffect(() => { const fetchUpdatedProject = async () => { @@ -89,7 +90,7 @@ export const AuctionCard = ({ project }: { project: Project }) => {
- {deployerLrns.length > 0 && ( + {deployerLrns?.length > 0 && (
Deployer LRNs {deployerLrns.map((lrn, index) => ( diff --git a/packages/frontend/src/pages/org-slug/projects/create/success/Id.tsx b/packages/frontend/src/pages/org-slug/projects/create/success/Id.tsx index b189d46f..5a0ac2df 100644 --- a/packages/frontend/src/pages/org-slug/projects/create/success/Id.tsx +++ b/packages/frontend/src/pages/org-slug/projects/create/success/Id.tsx @@ -52,7 +52,7 @@ const Id = () => { {/* Heading */}
- {isAuction? 'Auction created successfully.' : 'Project deployed successfully.'} + {isAuction? 'Auction created successfully.' : 'Project deployment created successfully.'}