Mercurial > sci
diff scid/page-index.c @ 57:bc617784ec97
scid: many fixes in pages
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 17 Aug 2022 18:26:27 +0200 |
parents | 3cf148705724 |
children | b0d1166de7d3 |
line wrap: on
line diff
--- a/scid/page-index.c Wed Aug 17 12:51:04 2022 +0200 +++ b/scid/page-index.c Wed Aug 17 18:26:27 2022 +0200 @@ -26,28 +26,24 @@ #include "util.h" static void -set_job_status(json_t *project, json_t *job, json_t *jobresults) +set_job_status(json_t *project, json_t *job, json_t *jobresults, size_t *ns, size_t *nf) { - json_t *iter; + json_t *iter, *status; int exitcode, sigcode; - size_t i, ns = 0, nf = 0; + size_t i; /* Compute number of failures and number of success. */ json_array_foreach(jobresults, i, iter) { json_unpack(iter, "{si si}", "exitcode", &exitcode, "sigcode", &sigcode); if (exitcode == 0 && sigcode == 0) - ns++; + (*ns)++; else - nf++; - - /* Also add exitcode and sigcode to the job object. */ - json_object_set_new(job, "exitcode", json_integer(exitcode)); - json_object_set_new(job, "sigcode", json_integer(sigcode)); + (*nf)++; } - json_object_set_new(project, "n-failed", json_integer(nf)); - json_object_set_new(project, "n-success", json_integer(ns)); + /* At least one failed, set status to false. */ + json_object_set_new(job, "status", json_boolean(nf)); } static void @@ -55,7 +51,7 @@ { json_t *iter, *jobresults; json_int_t job_id; - size_t i; + size_t i, ns = 0, nf = 0; json_array_foreach(jobs, i, iter) { /* Don't populate too much. */ @@ -74,11 +70,13 @@ if (!(jobresults = db_jobresult_list_by_job_group(job_id))) continue; - set_job_status(project, iter, jobresults); + set_job_status(project, iter, jobresults, &ns, &nf); json_decref(jobresults); } json_object_set_new(project, "jobs", jobs); + json_object_set_new(project, "n-failed", json_integer(nf)); + json_object_set_new(project, "n-success", json_integer(ns)); } /*