diff scid/page-index.c @ 73:b0d1166de7d3

themes: improve status
author David Demelier <markand@malikania.fr>
date Tue, 24 Jan 2023 10:51:48 +0100
parents bc617784ec97
children 070d8c92ca30
line wrap: on
line diff
--- a/scid/page-index.c	Tue Jan 24 10:22:55 2023 +0100
+++ b/scid/page-index.c	Tue Jan 24 10:51:48 2023 +0100
@@ -28,7 +28,8 @@
 static void
 set_job_status(json_t *project, json_t *job, json_t *jobresults, size_t *ns, size_t *nf)
 {
-	json_t *iter, *status;
+	const char *status;
+	json_t *iter;
 	int exitcode, sigcode;
 	size_t i;
 
@@ -42,8 +43,21 @@
 			(*nf)++;
 	}
 
-	/* At least one failed, set status to false. */
-	json_object_set_new(job, "status", json_boolean(nf));
+	/*
+	 * We have three possibilities:
+	 *
+	 * - unknown: no result performed,
+	 * - success: all results were successful,
+	 * - failed: at least one has failed.
+	 */
+	if (*nf == 0 && *ns == 0)
+		status = "unknown";
+	else if (*nf > 0)
+		status = "failed";
+	else
+		status = "success";
+
+	json_object_set_new(job, "status", json_string(status));
 }
 
 static void