Update method name to get record by Id
All checks were successful
Lint / lint (20.x) (pull_request) Successful in 4m40s

This commit is contained in:
IshaVenikar 2025-02-03 09:17:45 +05:30
parent f318a95641
commit a17386eb68
2 changed files with 51 additions and 50 deletions

View File

@ -442,9 +442,9 @@ export class Registry {
}
/**
* Fetch deployment DNS record by Id
* Fetch record by Id
*/
async getDNSRecordById(id: string): Promise<DNSRecord[]> {
async getRecordById(id: string): Promise<any[]> {
return this.registry.getRecordsByIds([id]);
}

View File

@ -22,6 +22,7 @@ import {
AppDeploymentRemovalRecord,
AuctionParams,
DeployerRecord,
DNSRecord,
DNSRecordAttributes,
EnvironmentVariables,
GitPushEventPayload,
@ -200,61 +201,61 @@ export class Service {
if (!deployment.project) {
log(`Project ${deployment.projectId} not found`);
return;
} else {
const dnsRecord = (await this.laconicRegistry.getDNSRecordById(record.attributes.dns))[0];
}
const dnsRecordData: DNSRecordAttributes = {
name: dnsRecord.attributes.name,
request: dnsRecord.attributes.request,
resourceType: dnsRecord.attributes.resourceType,
value: dnsRecord.attributes.value,
version: dnsRecord.attributes.version,
}
const dnsRecord: DNSRecord = (await this.laconicRegistry.getRecordById(record.attributes.dns))[0];
deployment.applicationDeploymentRecordId = record.id;
deployment.applicationDeploymentRecordData = record.attributes;
deployment.url = record.attributes.url;
deployment.status = DeploymentStatus.Ready;
deployment.isCurrent = deployment.environment === Environment.Production;
deployment.dnsRecordData = dnsRecordData;
const dnsRecordData: DNSRecordAttributes = {
name: dnsRecord.attributes.name,
request: dnsRecord.attributes.request,
resourceType: dnsRecord.attributes.resourceType,
value: dnsRecord.attributes.value,
version: dnsRecord.attributes.version,
}
if (deployment.isDNS) {
// Delete previous DNS deployment
const oldDNSDeployment = await this.db.getDeployment({
where: {
projectId: deployment.project.id,
deployer: deployment.deployer,
isDNS: true,
isCurrent: true,
}
});
deployment.applicationDeploymentRecordId = record.id;
deployment.applicationDeploymentRecordData = record.attributes;
deployment.url = record.attributes.url;
deployment.status = DeploymentStatus.Ready;
deployment.isCurrent = deployment.environment === Environment.Production;
deployment.dnsRecordData = dnsRecordData;
if (oldDNSDeployment) {
await this.db.deleteDeploymentById(oldDNSDeployment.id);
if (oldDNSDeployment.domain) {
await this.db.updateDeploymentById(deployment.id, { domain: oldDNSDeployment.domain })
}
if (deployment.isDNS) {
// Delete previous DNS deployment
const oldDNSDeployment = await this.db.getDeployment({
where: {
projectId: deployment.project.id,
deployer: deployment.deployer,
isDNS: true,
isCurrent: true,
}
});
if (oldDNSDeployment) {
await this.db.deleteDeploymentById(oldDNSDeployment.id);
if (oldDNSDeployment.domain) {
await this.db.updateDeploymentById(deployment.id, { domain: oldDNSDeployment.domain })
}
}
await this.db.updateDeploymentById(deployment.id, deployment);
// Release deployer funds on successful deployment
if (!deployment.project.fundsReleased) {
const fundsReleased = await this.releaseDeployerFundsByProjectId(deployment.projectId);
// Return remaining amount to owner
await this.returnUserFundsByProjectId(deployment.projectId, true);
await this.db.updateProjectById(deployment.projectId, {
fundsReleased,
});
}
log(
`Updated deployment ${deployment.id} with URL ${record.attributes.url}`,
);
}
await this.db.updateDeploymentById(deployment.id, deployment);
// Release deployer funds on successful deployment
if (!deployment.project.fundsReleased) {
const fundsReleased = await this.releaseDeployerFundsByProjectId(deployment.projectId);
// Return remaining amount to owner
await this.returnUserFundsByProjectId(deployment.projectId, true);
await this.db.updateProjectById(deployment.projectId, {
fundsReleased,
});
}
log(
`Updated deployment ${deployment.id} with URL ${record.attributes.url}`,
);
});
await Promise.all(deploymentUpdatePromises);