diff options
author | Christopher Baines <mail@cbaines.net> | 2020-01-12 17:30:52 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2020-01-12 17:30:52 +0000 |
commit | 2062badf5167d942c0eb96d7ca73e0906de7e36b (patch) | |
tree | d658f8e667e11a8f06193a7b910752239a473eb3 | |
parent | 331e3e789d164a80de277a5ce1a56f05d8fbc634 (diff) | |
download | data-service-2062badf5167d942c0eb96d7ca73e0906de7e36b.tar data-service-2062badf5167d942c0eb96d7ca73e0906de7e36b.tar.gz |
Add a small table of recent job events
To make it easier to see what recently happened.
-rw-r--r-- | guix-data-service/jobs/load-new-guix-revision.scm | 21 | ||||
-rw-r--r-- | guix-data-service/web/jobs/controller.scm | 4 | ||||
-rw-r--r-- | guix-data-service/web/jobs/html.scm | 33 |
3 files changed, 57 insertions, 1 deletions
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm index 038d74f..457f6cb 100644 --- a/guix-data-service/jobs/load-new-guix-revision.scm +++ b/guix-data-service/jobs/load-new-guix-revision.scm @@ -56,6 +56,7 @@ process-load-new-guix-revision-job select-job-for-commit select-jobs-and-events + select-recent-job-events select-unprocessed-jobs-and-events select-jobs-and-events-for-commit record-job-event @@ -1076,6 +1077,26 @@ RETURNING id;") (list commit)))) result)) +(define* (select-recent-job-events conn + #:key (limit 8)) + (define query + (string-append + " +SELECT + load_new_guix_revision_jobs.id, + load_new_guix_revision_jobs.commit, + load_new_guix_revision_jobs.source, + load_new_guix_revision_jobs.git_repository_id, + load_new_guix_revision_job_events.event, + load_new_guix_revision_job_events.occurred_at +FROM load_new_guix_revision_jobs +INNER JOIN load_new_guix_revision_job_events + ON load_new_guix_revision_job_events.job_id = load_new_guix_revision_jobs.id +ORDER BY load_new_guix_revision_job_events.occurred_at DESC +LIMIT " (number->string limit))) + + (exec-query conn query)) + (define (select-jobs-and-events conn before-id limit) (define query (string-append diff --git a/guix-data-service/web/jobs/controller.scm b/guix-data-service/web/jobs/controller.scm index 949fac2..733fb35 100644 --- a/guix-data-service/web/jobs/controller.scm +++ b/guix-data-service/web/jobs/controller.scm @@ -64,11 +64,13 @@ (jobs (select-jobs-and-events conn (assq-ref query-parameters 'before_id) - limit-results))) + limit-results)) + (recent-events (select-recent-job-events conn))) (render-html #:sxml (view-jobs query-parameters jobs + recent-events (and limit-results (>= (length jobs) limit-results)))))) diff --git a/guix-data-service/web/jobs/html.scm b/guix-data-service/web/jobs/html.scm index f2b45b2..830d0e6 100644 --- a/guix-data-service/web/jobs/html.scm +++ b/guix-data-service/web/jobs/html.scm @@ -26,6 +26,7 @@ (define (view-jobs query-parameters jobs-and-events + recent-events show-next-page?) (layout #:body @@ -49,6 +50,38 @@ (div (@ (class "row")) (div + (@ (class "col-sm-1"))) + (div + (@ (class "col-sm-10")) + (table + (@ (class "table")) + (thead + (tr + (th "Job") + (th "Event") + (th "Occurred at"))) + (tbody + ,@(map + (match-lambda + ((id commit source git-repository-id event occurred-at) + `(tr + (td (a (@ (href + ,(string-append + "/revision/" commit))) + (samp ,commit))) + (td ,@(let ((classes '(("start" . "info") + ("success" . "success") + ("failure" . "danger")))) + (or (and=> (assoc-ref classes event) + (lambda (class) + `((@ (class ,class))))) + '())) + ,event) + (td ,occurred-at)))) + recent-events))))) + (div + (@ (class "row")) + (div (@ (class "col-sm-12")) (div (@ (class "well")) |