Set isCurrent to false only for deployments from same deployer
All checks were successful
Lint / lint (20.x) (pull_request) Successful in 4m9s
All checks were successful
Lint / lint (20.x) (pull_request) Successful in 4m9s
This commit is contained in:
parent
e10c8f4818
commit
a9f50a02f0
@ -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<string> => {
|
||||
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<string>(),
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,8 @@ export interface GitPushEventPayload {
|
||||
|
||||
export interface AppDeploymentRecordAttributes {
|
||||
application: string;
|
||||
auction: string;
|
||||
deployer: string;
|
||||
dns: string;
|
||||
meta: string;
|
||||
name: string;
|
||||
|
@ -83,7 +83,7 @@ const DeploymentDetailsCard = ({
|
||||
|
||||
return (
|
||||
<div className="flex md:flex-row flex-col gap-6 py-4 px-3 pb-6 mb-2 last:mb-0 last:pb-4 border-b border-border-separator last:border-b-transparent relative">
|
||||
<div className="flex-1 flex justify-between w-full md:max-w-[25%] lg:max-w-[28%]">
|
||||
<div className="flex-1 flex justify-between w-full md:max-w-[30%] lg:max-w-[33%]">
|
||||
<div className="flex-1 w-full space-y-2 max-w-[90%] sm:max-w-full">
|
||||
{/* DEPLOYMENT URL */}
|
||||
{deployment.url && (
|
||||
@ -96,7 +96,12 @@ const DeploymentDetailsCard = ({
|
||||
</OverflownText>
|
||||
</Heading>
|
||||
)}
|
||||
<span className="text-sm text-elements-low-em tracking-tight">
|
||||
{deployment.deployerLrn && (
|
||||
<span className="text-sm text-elements-low-em tracking-tight block mt-2">
|
||||
Deployer LRN: {deployment.deployerLrn}
|
||||
</span>
|
||||
)}
|
||||
<span className="text-sm text-elements-low-em tracking-tight block">
|
||||
{deployment.environment === Environment.Production
|
||||
? `Production ${deployment.isCurrent ? '(Current)' : ''}`
|
||||
: 'Preview'}
|
||||
|
@ -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 }) => {
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{deployerLrns.length > 0 && (
|
||||
{deployerLrns?.length > 0 && (
|
||||
<div className="mt-3">
|
||||
<span className="text-elements-high-em text-sm font-medium tracking-tight">Deployer LRNs</span>
|
||||
{deployerLrns.map((lrn, index) => (
|
||||
|
@ -52,7 +52,7 @@ const Id = () => {
|
||||
{/* Heading */}
|
||||
<div className="flex flex-col items-center gap-1.5">
|
||||
<Heading as="h3" className="font-medium text-xl">
|
||||
{isAuction? 'Auction created successfully.' : 'Project deployed successfully.'}
|
||||
{isAuction? 'Auction created successfully.' : 'Project deployment created successfully.'}
|
||||
</Heading>
|
||||
</div>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user