From: Michael Tremer Date: Sat, 29 Apr 2023 11:36:30 +0000 (+0000) Subject: events: Add jobs X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc29422a164117ad9f34fe3fac29d71601d8f45b;p=pbs.git events: Add jobs Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/events.py b/src/buildservice/events.py index 0602c216..95f41d85 100644 --- a/src/buildservice/events.py +++ b/src/buildservice/events.py @@ -32,7 +32,7 @@ log = logging.getLogger("pbs.events") # WARNING : 8 # MAJOR INFO : 5 # MINOR INFO : 4 -# DEBUG : 0 +# DEBUG : 1 # The view returns the following fields # type (of the event) @@ -41,6 +41,7 @@ log = logging.getLogger("pbs.events") # build # by_build # build_comment +# job # user # by_user # repository @@ -55,6 +56,7 @@ EVENTS_VIEW = """ builds.id AS build, NULL::integer AS by_build, NULL::integer AS build_comment, + NULL::integer AS job, NULL::integer AS user, builds.owner_id AS by_user, NULL::integer AS repository @@ -79,6 +81,7 @@ EVENTS_VIEW = """ builds.id AS build, NULL AS by_build, NULL AS build_comment, + NULL AS job, NULL AS user, NULL AS by_user, NULL AS repository @@ -97,6 +100,7 @@ EVENTS_VIEW = """ builds.id AS build, NULL AS by_build, NULL AS build_comment, + NULL AS job, NULL AS user, builds.deleted_by AS by_user, NULL AS repository @@ -116,6 +120,7 @@ EVENTS_VIEW = """ builds.id AS build, builds.deprecating_build_id AS by_build, NULL AS build_comment, + NULL AS job, NULL AS user, builds.deprecated_by AS by_user, NULL AS repository @@ -136,6 +141,7 @@ EVENTS_VIEW = """ build_comments.build_id AS build, NULL AS by_build, build_comments.id AS build_comment, + NULL AS job, NULL AS user, build_comments.user_id AS by_user, NULL AS repository @@ -154,6 +160,7 @@ EVENTS_VIEW = """ build_watchers.build_id AS build, NULL AS by_build, NULL AS build_comment, + NULL AS job, build_watchers.user_id AS user, NULL AS by_user, NULL AS repository @@ -170,6 +177,7 @@ EVENTS_VIEW = """ build_watchers.build_id AS build, NULL AS by_build, NULL AS build_comment, + NULL AS job, build_watchers.user_id AS user, NULL AS by_user, NULL AS repository @@ -188,6 +196,7 @@ EVENTS_VIEW = """ repository_builds.build_id AS build, NULL AS by_build, NULL AS build_comment, + NULL AS job, NULL AS user, repository_builds.added_by AS by_user, repository_builds.repo_id AS repository @@ -204,6 +213,7 @@ EVENTS_VIEW = """ repository_builds.build_id AS build, NULL AS by_build, NULL AS build_comment, + NULL AS job, NULL AS user, repository_builds.removed_by AS by_user, repository_builds.repo_id AS repository @@ -211,6 +221,117 @@ EVENTS_VIEW = """ repository_builds WHERE removed_at IS NOT NULL + + UNION ALL + + -- Jobs Creations + SELECT + 'job-created' AS type, + jobs.created_at AS t, + 3 AS priority, + jobs.build_id AS build, + NULL AS by_build, + NULL AS build_comment, + jobs.id AS job, + NULL AS user, + NULL AS by_user, + NULL AS repository + FROM + jobs + WHERE + jobs.deleted_at IS NULL + + UNION ALL + + -- Failed Jobs + SELECT + 'job-failed' AS type, + jobs.finished_at AS t, + 5 AS priority, + jobs.build_id AS build, + NULL AS by_build, + NULL AS build_comment, + jobs.id AS job, + NULL AS user, + NULL AS by_user, + NULL AS repository + FROM + jobs + WHERE + jobs.deleted_at IS NULL + AND + jobs.finished_at IS NOT NULL + AND + jobs.aborted IS FALSE + AND + jobs.failed IS TRUE + + UNION ALL + + -- Finished Jobs + SELECT + 'job-finished' AS type, + jobs.finished_at AS t, + 4 AS priority, + jobs.build_id AS build, + NULL AS by_build, + NULL AS build_comment, + jobs.id AS job, + NULL AS user, + NULL AS by_user, + NULL AS repository + FROM + jobs + WHERE + jobs.deleted_at IS NULL + AND + jobs.finished_at IS NOT NULL + AND + jobs.aborted IS FALSE + AND + jobs.failed IS FALSE + + UNION ALL + + -- Aborted Jobs + SELECT + 'job-aborted' AS type, + jobs.finished_at AS t, + 4 AS priority, + jobs.build_id AS build, + NULL AS by_build, + NULL AS build_comment, + jobs.id AS job, + NULL AS user, + jobs.aborted_by AS by_user, + NULL AS repository + FROM + jobs + WHERE + jobs.deleted_at IS NULL + AND + jobs.aborted IS TRUE + + UNION ALL + + -- Dispatched Jobs + SELECT + 'job-dispatched' AS type, + jobs.started_at AS t, + 1 AS priority, + jobs.build_id AS build, + NULL AS by_build, + NULL AS build_comment, + jobs.id AS job, + NULL AS user, + NULL AS by_user, + NULL AS repository + FROM + jobs + WHERE + jobs.deleted_at IS NULL + AND + jobs.started_at IS NOT NULL ) """ @@ -225,6 +346,9 @@ class Events(base.Object): # Build Comments "build_comment" : self.backend.builds.comments.get_by_id, + # Jobs + "job" : self.backend.jobs.get_by_id, + # Repositories "repository" : self.backend.repos.get_by_id, diff --git a/src/templates/events/modules/system-message.html b/src/templates/events/modules/system-message.html index cd22bb52..bb32b1c7 100644 --- a/src/templates/events/modules/system-message.html +++ b/src/templates/events/modules/system-message.html @@ -1,11 +1,11 @@
{% block thumbnail %}
- {% if event.type == "build-failed" %} + {% if event.type in ("build-failed", "job-failed") %} - {% elif event.type == "build-finished" %} + {% elif event.type in ("build-finished", "job-finished") %} @@ -33,6 +33,16 @@ {{ _("%s started watching this build") % event.user }} {% elif event.type == "build-watcher-removed" %} {{ _("%s stopped watching this build") % event.user }} + {% elif event.type == "job-created" %} + {{ _("Job Created") }} + {% elif event.type == "job-failed" %} + {{ _("Job Failed") }} + {% elif event.type == "job-finished" %} + {{ _("Job Finished") }} + {% elif event.type == "job-aborted" %} + {{ _("Job Aborted") }} + {% elif event.type == "job-dispatched" %} + {{ _("Job Dispatched") }} {% elif event.type == "repository-build-added" %} {{ _("Build has been added to repository %s") % event.repository }} {% elif event.type == "repository-build-removed" %} @@ -49,7 +59,7 @@