Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
josepablofm78 committed Dec 5, 2022
1 parent 657bb3f commit 6195768
Showing 1 changed file with 52 additions and 47 deletions.
99 changes: 52 additions & 47 deletions src/compute/compute.service.ts
Expand Up @@ -18,11 +18,11 @@ export type WorkflowStatus = {
pods: PodStatus[]
}

export type PodStatus = {
podName: string
status: string
startedAt: string
finishedAt: string
export type PodStatus = {
podName: string
status: string
startedAt: string
finishedAt: string
}

@Injectable()
Expand All @@ -39,62 +39,67 @@ export class ComputeService {
}

async createWorkflowStatus(responseBody: any, workflowID: string): Promise<WorkflowStatus> {

let result: WorkflowStatus = {startedAt: "null", finishedAt: "null", status: "null", did: undefined, pods: []}
let result: WorkflowStatus = {
startedAt: 'null',
finishedAt: 'null',
status: 'null',
did: undefined,
pods: [],
}
const pods = []

// Transform from pairs of id:object to array of objects
const nodesPairs = responseBody.status.nodes

if (nodesPairs) {

const nodesArray = []
for (const i in nodesPairs) {
if (nodesPairs) {
const nodesArray = []
for (const i in nodesPairs) {
nodesArray.push(nodesPairs[i])
}

nodesArray.forEach((element) => {
const podName = element.displayName
if (podName === workflowID) {
result.status = element.phase
result.startedAt = element.startedAt
result.finishedAt = element.finishedAt
} else {
const podStatus: PodStatus = {
podName: podName,
status: element.phase,
startedAt: element.startedAt,
finishedAt: element.finishedAt,
}
pods.push(podStatus)
}
})

result.pods = pods

if (result.status === 'Succeeded') {
const query = {
nested: {
path: 'service',
query: {
match: {
'service.attributes.additionalInformation.customData.workflowID': workflowID,
},
},
},
}

nodesArray.forEach((element) => {
const podName = element.displayName
if (podName === workflowID) {
result.status = element.phase
result.startedAt = element.startedAt
result.finishedAt = element.finishedAt
} else {
const podStatus: PodStatus = {
podName: podName,
status: element.phase,
startedAt: element.startedAt,
finishedAt: element.finishedAt,
}
pods.push(podStatus)
}
})

result.pods = pods

if (result.status === 'Succeeded') {
const query = {
nested: {
path: 'service',
query: {
match: { 'service.attributes.additionalInformation.customData.workflowID': workflowID },
},
},
}

const queryResult = await this.nvmService.getNevermined().assets.query({ query: query })

if (queryResult.totalResults.value > 0) {
const did = queryResult.results[0].id
result.did = did
}
const queryResult = await this.nvmService.getNevermined().assets.query({ query: query })

if (queryResult.totalResults.value > 0) {
const did = queryResult.results[0].id
result.did = did
}
}
}

return result
}


private readWorkflowTemplate(): any {
const templatePath = path.join(
__dirname,
Expand Down

0 comments on commit 6195768

Please sign in to comment.