]> git.ipfire.org Git - pbs.git/commitdiff
builds: Show when builds have been added to/removed from a repository
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Mar 2023 16:35:54 +0000 (16:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 9 Mar 2023 16:35:54 +0000 (16:35 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/events.py
src/templates/events/modules/system-message.html

index 1b36f1b32414193749463e3a5fa930b30a1e6fa1..de1d9ef52e2f04b99f7b208093af0d02fe5b6f8e 100644 (file)
@@ -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,
index 997e57e905c07eda17f4680c2b74341dac376910..0ec093737211a6c27bdbb7143647057bb0186761 100644 (file)
                                {{ _("%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 %}
                                        </a>
                                {% end %}
 
+                               {# Repository #}
+                               {% if event.repository %}
+                                       <a class="level-item" href="{{ event.repository.url }}">
+                                               {{ event.repository }}
+                                       </a>
+                               {% end %}
+
                                {# By User #}
                                {% if event.by_user %}
                                        <a class="level-item" href="/users/{{ event.by_user.name }}">