changeset 5717:1c3bdd114ca1 errors-in-csv-export

Add errors column to CSV export.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 11 Dec 2023 16:16:57 +0100
parents 6bf942f486e9
children 2a1eff7c4af0
files pkg/controllers/importqueue.go
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/controllers/importqueue.go	Thu Dec 07 16:56:24 2023 +0100
+++ b/pkg/controllers/importqueue.go	Mon Dec 11 16:16:57 2023 +0100
@@ -74,6 +74,8 @@
   signer,
   EXISTS(SELECT 1 FROM import.import_logs
     WHERE kind = 'warn'::log_type and import_id = id) AS has_warnings,
+  EXISTS(SELECT 1 FROM import.import_logs
+    WHERE kind = 'error'::log_type and import_id = id) AS has_errors,
   data,
   CASE WHEN kind = ANY($1) THEN ARRAY(SELECT msg FROM import.import_logs WHERE import_id = id)
   ELSE NULL
@@ -311,6 +313,7 @@
 		"#signer",
 		"#state",
 		"#warnings",
+		"#errors",
 		"#source",
 	}
 
@@ -346,6 +349,7 @@
 		country  string
 		signer   sql.NullString
 		warnings bool
+		errors   bool
 		data     string
 		msgs     pgtype.TextArray
 	}
@@ -395,7 +399,8 @@
 		record[6] = signer
 		record[7] = ds.state
 		record[8] = strconv.FormatBool(ds.warnings)
-		record[9] = description
+		record[9] = strconv.FormatBool(ds.errors)
+		record[10] = description
 
 		return out.Write(record)
 	}
@@ -413,6 +418,7 @@
 			&curr.country,
 			&curr.signer,
 			&curr.warnings,
+			&curr.errors,
 			&curr.data,
 			&curr.msgs,
 		); err != nil {