From 2319938ea07f0b96eaa0e322ea00aa04f60707fa Mon Sep 17 00:00:00 2001 From: Vitalie Belinschi Date: Thu, 19 Sep 2024 10:47:52 +0200 Subject: [PATCH] check failed status only for currently running reports --- .../SettlementReportListHttpTrigger.cs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/source/settlement-report/Orchestration.SettlementReports/Functions/SettlementReports/SettlementReportListHttpTrigger.cs b/source/settlement-report/Orchestration.SettlementReports/Functions/SettlementReports/SettlementReportListHttpTrigger.cs index b327210..01a1700 100644 --- a/source/settlement-report/Orchestration.SettlementReports/Functions/SettlementReports/SettlementReportListHttpTrigger.cs +++ b/source/settlement-report/Orchestration.SettlementReports/Functions/SettlementReports/SettlementReportListHttpTrigger.cs @@ -98,23 +98,23 @@ private async Task> CheckStatusOfSettl foreach (var settlementReport in settlementReports) { var updatedReport = settlementReport; - if (settlementReport.JobId == null) - { - var instanceInfo = await durableTaskClient - .GetInstanceAsync(settlementReport.RequestId.Id, getInputsAndOutputs: true) - .ConfigureAwait(false); - if (instanceInfo == null) - { - // If the orchestration instance is not found, we assume it is running on the other orchestration, - // either the heavy or the light one - continue; - } + var instanceInfo = await durableTaskClient + .GetInstanceAsync(settlementReport.RequestId.Id, getInputsAndOutputs: true) + .ConfigureAwait(false); + if (instanceInfo == null) + { + // If the orchestration instance is not found, we assume it is running on the other orchestration, + // either the heavy or the light one + continue; + } + + if (settlementReport.Status == SettlementReportStatus.InProgress) + { if (instanceInfo.RuntimeStatus - is not OrchestrationRuntimeStatus.Running - and not OrchestrationRuntimeStatus.Pending - and not OrchestrationRuntimeStatus.Suspended) + is OrchestrationRuntimeStatus.Terminated + or OrchestrationRuntimeStatus.Failed) { await _updateFailedSettlementReportsHandler .UpdateFailedReportAsync(settlementReport.RequestId) @@ -130,9 +130,9 @@ await _updateFailedSettlementReportsHandler updatedReport = updatedReport with { Progress = customStatus.OrchestrationProgress }; } } - - finalSettlementReports.Add(updatedReport); } + + finalSettlementReports.Add(updatedReport); } return finalSettlementReports;