From 8b8b7e7a1ab49b9bb5e648f5b9bf4b5e1de88783 Mon Sep 17 00:00:00 2001
From: Nathan Bockisch <nbockisc@nrao.edu>
Date: Tue, 25 Apr 2023 10:55:17 -0600
Subject: [PATCH] Changed pims_analyzer to report failure/success based on if
 there were failed splits or not

---
 .../go/pims_analyzer/pkg/pims/get_data.go           | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/apps/cli/executables/go/pims_analyzer/pkg/pims/get_data.go b/apps/cli/executables/go/pims_analyzer/pkg/pims/get_data.go
index cfd8c4398..74323befc 100644
--- a/apps/cli/executables/go/pims_analyzer/pkg/pims/get_data.go
+++ b/apps/cli/executables/go/pims_analyzer/pkg/pims/get_data.go
@@ -58,7 +58,6 @@ type PimsInfo struct {
 // database
 type workflowEntry struct {
     arguments []byte
-    state string
     resultsDir string
 }
 
@@ -111,8 +110,12 @@ func GetPimsInfo(workflowId int, capoPath string, capoProfile string) PimsInfo {
             strings.Replace(capoProfile, "dsoc-", "vlass_", -1),
             pimsInfo.Calibration,
         )
-    pimsInfo.StatusMsg = fmt.Sprintf("PIMS Split workflow completed with state: %s",
-            wfEntry.state,
+
+    // Workflow reported as failed when there are failed splits
+    status := "succeeded"
+    if (pimsInfo.NumFailedSplits != 0) { status = "failed" }
+    pimsInfo.StatusMsg = fmt.Sprintf("PIMS Split workflow %s!",
+            status,
         )
 
     // Check if there's a Restored MS Path
@@ -163,7 +166,7 @@ func GetPimsInfo(workflowId int, capoPath string, capoProfile string) PimsInfo {
 func getWorkflowColumns(workflowId int, dbConnection *sql.DB) (workflowEntry, error) {
     workflowTable := "workflow_requests"
     workflowIdKey := "workflow_request_id"
-    dataCols := "argument,state,results_dir"
+    dataCols := "argument,results_dir"
 
     var entry workflowEntry
     // var tmpArgs string // Must get JSON as string first
@@ -177,7 +180,7 @@ func getWorkflowColumns(workflowId int, dbConnection *sql.DB) (workflowEntry, er
             workflowTable,
             workflowIdKey,
             workflowId),
-        ).Scan(&entry.arguments, &entry.state, &entry.resultsDir)
+        ).Scan(&entry.arguments, &entry.resultsDir)
 
     return entry, err
 }
-- 
GitLab