Skip to content

Commit

Permalink
improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
salmma committed Aug 7, 2024
1 parent 3ab308e commit 6e40031
Showing 1 changed file with 58 additions and 49 deletions.
107 changes: 58 additions & 49 deletions src/app/components/algorithms/nisq-analyzer/nisq-analyzer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,57 +502,66 @@ export class NisqAnalyzerComponent implements OnInit {
.afterClosed()
.subscribe((dialogResult) => {
if (dialogResult) {
this.loadingResults[analysisResult.id] = true;
this.results = undefined;
const executeBodyDto: ExecuteAnalysisResultRequestDto = {
tokens: this.setVendorTokens(
[analysisResult.provider],
dialogResult.ibmqToken,
dialogResult.ionqToken,
dialogResult.awsToken,
dialogResult.awsSecretToken
),
};

this.qpuSelectionService
.executeQpuSelectionResult({
resId: analysisResult.id,
body: executeBodyDto,
})
.subscribe(
(results) => {
if (
results.status === 'FAILED' ||
results.status === 'FINISHED'
) {
this.results = results;
} else {
interval(1000)
.pipe(
exhaustMap(() =>
this.http.get<ExecutionResultDto>(
results._links['self'].href
this.analyzerJob.analysisResultList.forEach((anaResult) => {
if (
analysisResult.qpuSelectionJobId === anaResult.qpuSelectionJobId
) {
this.loadingResults[analysisResult.id] = true;
this.results = undefined;
const executeBodyDto: ExecuteAnalysisResultRequestDto = {
correlationId: anaResult.correlationId,
tokens: this.setVendorTokens(
[analysisResult.provider],
dialogResult.ibmqToken,
dialogResult.ionqToken,
dialogResult.awsToken,
dialogResult.awsSecretToken
),
};

this.qpuSelectionService
.executeQpuSelectionResult({
resId: analysisResult.id,
body: executeBodyDto,
})
.subscribe(
(results) => {
if (
results.status === 'FAILED' ||
results.status === 'FINISHED'
) {
this.results = results;
} else {
interval(1000)
.pipe(
exhaustMap(() =>
this.http.get<ExecutionResultDto>(
results._links['self'].href
)
),
first(
(value) =>
value.status === 'FAILED' ||
value.status === 'FINISHED'
)
)
),
first(
(value) =>
value.status === 'FAILED' ||
value.status === 'FINISHED'
)
)
.subscribe((finalResult) => (this.results = finalResult));
}
this.utilService.callSnackBar(
'Successfully started execution "' + results.id + '".'
);
this.hasExecutionResult(analysisResult);
},
() => {
this.utilService.callSnackBar(
'Error! Could not start execution.'
.subscribe(
(finalResult) => (this.results = finalResult)
);
}
this.utilService.callSnackBar(
'Successfully started execution "' + results.id + '".'
);
this.hasExecutionResult(analysisResult);
},
() => {
this.utilService.callSnackBar(
'Error! Could not start execution.'
);
}
);
}
);
}
});
}
});
}
Expand Down

0 comments on commit 6e40031

Please sign in to comment.