Skip to content

Commit

Permalink
Enhanced the code by adding a continue statements
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmoud-Emad committed Oct 9, 2023
1 parent 0bd8e39 commit 581f09b
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions packages/grid_client/src/high_level/twinDeploymentHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TFClient } from "../clients/tf-grid/client";
import { GridClientConfig } from "../config";
import { events } from "../helpers/events";
import { validateObject } from "../helpers/validator";
import { DeploymentFactory, NodeInfo, Nodes } from "../primitives/index";
import { DeploymentFactory, Nodes } from "../primitives/index";
import { Workload, WorkloadTypes } from "../zos/workload";
import { Operations, TwinDeployment } from "./models";
class TwinDeploymentHandler {
Expand Down Expand Up @@ -269,15 +269,22 @@ class TwinDeploymentHandler {
const farmIPs: Map<number, number> = new Map();

for (const twinDeployment of twinDeployments) {
if (twinDeployment.operation === Operations.deploy) {
const node = await this.nodes.getNode(twinDeployment.nodeId);
if (node) {
if (!farmIPs.has(node.farmId)) {
farmIPs.set(node.farmId, twinDeployment.publicIps);
} else {
farmIPs.set(node.farmId, farmIPs.get(node.farmId)! + twinDeployment.publicIps);
}
}
if (twinDeployment.operation !== Operations.deploy) {
continue;
}

if (twinDeployment.publicIps === 0) {
continue;
}

const node = await this.nodes.getNode(twinDeployment.nodeId);
if (!node) {
continue;
}
if (!farmIPs.has(node.farmId)) {
farmIPs.set(node.farmId, twinDeployment.publicIps);
} else {
farmIPs.set(node.farmId, farmIPs.get(node.farmId)! + twinDeployment.publicIps);
}
}

Expand Down

0 comments on commit 581f09b

Please sign in to comment.