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({
|
const deployments = await this.db.getDeployments({
|
||||||
where: records.map((record) => ({
|
where: records.map((record) => ({
|
||||||
applicationRecordId: record.attributes.application,
|
applicationRecordId: record.attributes.application,
|
||||||
|
// Only for the specific deployer
|
||||||
|
deployerLrn: record.attributes.deployer
|
||||||
})),
|
})),
|
||||||
order: {
|
order: {
|
||||||
createdAt: 'DESC',
|
createdAt: 'DESC',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get project IDs of deployments that are in production environment
|
// Get deployment IDs of deployments that are in production environment
|
||||||
const productionDeploymentProjectIds = deployments.reduce(
|
const productionDeploymentIds: string[] = [];
|
||||||
(acc, deployment): Set<string> => {
|
deployments.forEach(deployment => {
|
||||||
if (deployment.environment === Environment.Production) {
|
if (deployment.environment === Environment.Production) {
|
||||||
acc.add(deployment.projectId);
|
if (!productionDeploymentIds.includes(deployment.id)) {
|
||||||
|
productionDeploymentIds.push(deployment.id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return acc;
|
});
|
||||||
},
|
|
||||||
new Set<string>(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Set old deployments isCurrent to false
|
// Set old deployments isCurrent to false
|
||||||
await this.db.updateDeploymentsByProjectIds(
|
// TODO: Only set isCurrent to false for the deployment for that specific deployer
|
||||||
Array.from(productionDeploymentProjectIds),
|
for (const deploymentId of productionDeploymentIds) {
|
||||||
{ isCurrent: false },
|
await this.db.updateDeployment(
|
||||||
|
{ id: deploymentId },
|
||||||
|
{ isCurrent: false }
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const recordToDeploymentsMap = deployments.reduce(
|
const recordToDeploymentsMap = deployments.reduce(
|
||||||
(acc: { [key: string]: Deployment }, deployment) => {
|
(acc: { [key: string]: Deployment }, deployment) => {
|
||||||
@ -303,7 +306,13 @@ export class Service {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Should only check on the first deployment
|
// 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 auctionIds = projects.map((project) => project.auctionId);
|
||||||
const completedAuctionIds = await this.laconicRegistry.getCompletedAuctionIds(auctionIds);
|
const completedAuctionIds = await this.laconicRegistry.getCompletedAuctionIds(auctionIds);
|
||||||
@ -314,14 +323,16 @@ export class Service {
|
|||||||
);
|
);
|
||||||
|
|
||||||
for (const project of projectsToBedeployed) {
|
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
|
// Update project with deployer LRNs
|
||||||
await this.db.updateProjectById(project.id!, {
|
await this.db.updateProjectById(project.id!, {
|
||||||
deployerLrns
|
deployerLrns
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const deployer of deployerLrns) {
|
for (const deployer of deployerLrns) {
|
||||||
|
log(`Creating deployment for deployer LRN ${deployer}`);
|
||||||
await this.createDeploymentFromAuction(project, deployer);
|
await this.createDeploymentFromAuction(project, deployer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -838,6 +849,7 @@ export class Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const project = await this.db.addProject(user, organization.id, data);
|
const project = await this.db.addProject(user, organization.id, data);
|
||||||
|
log(`Project created ${project.id}`);
|
||||||
|
|
||||||
const octokit = await this.getOctokit(user.id);
|
const octokit = await this.getOctokit(user.id);
|
||||||
const [owner, repo] = project.repository.split('/');
|
const [owner, repo] = project.repository.split('/');
|
||||||
@ -870,8 +882,6 @@ export class Service {
|
|||||||
|
|
||||||
await this.createRepoHook(octokit, project);
|
await this.createRepoHook(octokit, project);
|
||||||
|
|
||||||
console.log('projectid is', project.id);
|
|
||||||
|
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ export interface GitPushEventPayload {
|
|||||||
|
|
||||||
export interface AppDeploymentRecordAttributes {
|
export interface AppDeploymentRecordAttributes {
|
||||||
application: string;
|
application: string;
|
||||||
|
auction: string;
|
||||||
|
deployer: string;
|
||||||
dns: string;
|
dns: string;
|
||||||
meta: string;
|
meta: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -83,7 +83,7 @@ const DeploymentDetailsCard = ({
|
|||||||
|
|
||||||
return (
|
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 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">
|
<div className="flex-1 w-full space-y-2 max-w-[90%] sm:max-w-full">
|
||||||
{/* DEPLOYMENT URL */}
|
{/* DEPLOYMENT URL */}
|
||||||
{deployment.url && (
|
{deployment.url && (
|
||||||
@ -96,7 +96,12 @@ const DeploymentDetailsCard = ({
|
|||||||
</OverflownText>
|
</OverflownText>
|
||||||
</Heading>
|
</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
|
{deployment.environment === Environment.Production
|
||||||
? `Production ${deployment.isCurrent ? '(Current)' : ''}`
|
? `Production ${deployment.isCurrent ? '(Current)' : ''}`
|
||||||
: 'Preview'}
|
: 'Preview'}
|
||||||
|
@ -28,7 +28,8 @@ export const AuctionCard = ({ project }: { project: Project }) => {
|
|||||||
const result = await client.getAuctionData(project.auctionId);
|
const result = await client.getAuctionData(project.auctionId);
|
||||||
setAuctionStatus(result.status);
|
setAuctionStatus(result.status);
|
||||||
setAuctionDetails(result);
|
setAuctionDetails(result);
|
||||||
}, [client, project.auctionId]);
|
setDeployerLrns(project.deployerLrns);
|
||||||
|
}, [client, project.auctionId, project.deployerLrns]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchUpdatedProject = async () => {
|
const fetchUpdatedProject = async () => {
|
||||||
@ -89,7 +90,7 @@ export const AuctionCard = ({ project }: { project: Project }) => {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{deployerLrns.length > 0 && (
|
{deployerLrns?.length > 0 && (
|
||||||
<div className="mt-3">
|
<div className="mt-3">
|
||||||
<span className="text-elements-high-em text-sm font-medium tracking-tight">Deployer LRNs</span>
|
<span className="text-elements-high-em text-sm font-medium tracking-tight">Deployer LRNs</span>
|
||||||
{deployerLrns.map((lrn, index) => (
|
{deployerLrns.map((lrn, index) => (
|
||||||
|
@ -52,7 +52,7 @@ const Id = () => {
|
|||||||
{/* Heading */}
|
{/* Heading */}
|
||||||
<div className="flex flex-col items-center gap-1.5">
|
<div className="flex flex-col items-center gap-1.5">
|
||||||
<Heading as="h3" className="font-medium text-xl">
|
<Heading as="h3" className="font-medium text-xl">
|
||||||
{isAuction? 'Auction created successfully.' : 'Project deployed successfully.'}
|
{isAuction? 'Auction created successfully.' : 'Project deployment created successfully.'}
|
||||||
</Heading>
|
</Heading>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user