From: Michael Tremer Date: Thu, 9 Mar 2023 16:35:54 +0000 (+0000) Subject: builds: Show when builds have been added to/removed from a repository X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=79d48fd1f79b8398bde46dcc32701ff929ca924e;p=pbs.git builds: Show when builds have been added to/removed from a repository Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/events.py b/src/buildservice/events.py index 1b36f1b3..de1d9ef5 100644 --- a/src/buildservice/events.py +++ b/src/buildservice/events.py @@ -43,6 +43,7 @@ log = logging.getLogger("pakfire.buildservice.events") # build_comment # user # by_user +# repository # EVENTS_VIEW = """ WITH events AS ( @@ -55,7 +56,8 @@ EVENTS_VIEW = """ NULL::integer AS by_build, NULL::integer AS build_comment, NULL::integer AS user, - builds.owner_id AS by_user + builds.owner_id AS by_user, + NULL::integer AS repository FROM builds @@ -78,7 +80,8 @@ EVENTS_VIEW = """ NULL AS by_build, NULL AS build_comment, NULL AS user, - NULL AS by_user + NULL AS by_user, + NULL AS repository FROM builds WHERE @@ -95,7 +98,8 @@ EVENTS_VIEW = """ NULL AS by_build, NULL AS build_comment, NULL AS user, - builds.deleted_by AS by_user + builds.deleted_by AS by_user, + NULL AS repository FROM builds WHERE @@ -113,7 +117,8 @@ EVENTS_VIEW = """ builds.deprecating_build_id AS by_build, NULL AS build_comment, NULL AS user, - builds.deprecated_by AS by_user + builds.deprecated_by AS by_user, + NULL AS repository FROM builds WHERE @@ -132,7 +137,8 @@ EVENTS_VIEW = """ NULL AS by_build, build_comments.id AS build_comment, NULL AS user, - build_comments.user_id AS by_user + build_comments.user_id AS by_user, + NULL AS repository FROM build_comments WHERE @@ -149,7 +155,8 @@ EVENTS_VIEW = """ NULL AS by_build, NULL AS build_comment, build_watchers.user_id AS user, - NULL AS by_user + NULL AS by_user, + NULL AS repository FROM build_watchers @@ -164,11 +171,46 @@ EVENTS_VIEW = """ NULL AS by_build, NULL AS build_comment, build_watchers.user_id AS user, - NULL AS by_user + NULL AS by_user, + NULL AS repository FROM build_watchers WHERE deleted_at IS NOT NULL + + UNION ALL + + -- Build added to repository + SELECT + 'repository-build-added' AS type, + repository_builds.added_at AS t, + 5 AS priority, + repository_builds.build_id AS build, + NULL AS by_build, + NULL AS build_comment, + NULL AS user, + repository_builds.added_by AS by_user, + repository_builds.repo_id AS repository + FROM + repository_builds + + UNION ALL + + -- Build removed from repository + SELECT + 'repository-build-removed' AS type, + repository_builds.removed_at AS t, + 5 AS priority, + repository_builds.build_id AS build, + NULL AS by_build, + NULL AS build_comment, + NULL AS user, + repository_builds.removed_by AS by_user, + repository_builds.repo_id AS repository + FROM + repository_builds + WHERE + removed_at IS NOT NULL ) """ @@ -183,6 +225,9 @@ class Events(base.Object): # Build Comments "build_comment" : self.backend.builds.comments.get_by_id, + # Repositories + "repository" : self.backend.repos.get_by_id, + # Users "user" : self.backend.users.get_by_id, "by_user" : self.backend.users.get_by_id, diff --git a/src/templates/events/modules/system-message.html b/src/templates/events/modules/system-message.html index 997e57e9..0ec09373 100644 --- a/src/templates/events/modules/system-message.html +++ b/src/templates/events/modules/system-message.html @@ -13,6 +13,10 @@ {{ _("%s started watching this build") % event.user }} {% elif event.type == "build-watcher-removed" %} {{ _("%s stopped watching this build") % event.user }} + {% elif event.type == "repository-build-added" %} + {{ _("Build has been added to repository %s") % event.repository }} + {% elif event.type == "repository-build-removed" %} + {{ _("Build has been removed from repository %s") % event.repository }} {% else %} {{ _("- Unknown Event -") }} {% end %} @@ -38,6 +42,13 @@ {% end %} + {# Repository #} + {% if event.repository %} + + {{ event.repository }} + + {% end %} + {# By User #} {% if event.by_user %}