]> git.ipfire.org Git - pbs.git/commitdiff
events: Show deprecated builds
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Oct 2022 11:52:44 +0000 (11:52 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 25 Oct 2022 11:52:44 +0000 (11:52 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/events.py
src/templates/events/modules/system-message.html

index 767f5c077c8964b29e72d45b79d92c34932bbb65..b37a15d3ec9d638b7c5ba845129270643d029df8 100644 (file)
@@ -39,6 +39,8 @@ log = logging.getLogger("pakfire.buildservice.events")
 # t (timestamp)
 # priority
 # build
+# by_build
+# build_comment
 # user
 # by_user
 #
@@ -50,6 +52,7 @@ EVENTS_VIEW = """
                        builds.created_at AS t,
                        4 AS priority,
                        builds.id AS build,
+                       NULL::integer AS by_build,
                        NULL::integer AS build_comment,
                        NULL::integer AS user,
                        builds.owner_id AS by_user
@@ -72,6 +75,7 @@ EVENTS_VIEW = """
                                ELSE 4
                        END AS priority,
                        builds.id AS build,
+                       NULL AS by_build,
                        NULL AS build_comment,
                        NULL AS user,
                        NULL AS by_user
@@ -88,6 +92,7 @@ EVENTS_VIEW = """
                        builds.deleted_at AS t,
                        4 AS priority,
                        builds.id AS build,
+                       NULL AS by_build,
                        NULL AS build_comment,
                        NULL AS user,
                        builds.deleted_by AS by_user
@@ -98,12 +103,37 @@ EVENTS_VIEW = """
 
                UNION ALL
 
+               -- Deprecated Builds
+
+               SELECT
+                       'build-deprecated' AS type,
+                       deprecated_builds.created_at AS t,
+                       4 AS priority,
+                       builds.id AS build,
+                       builds.deprecated_by AS by_build,
+                       NULL AS build_comment,
+                       NULL AS user,
+                       builds.owner_id AS by_user
+               FROM
+                       builds
+               LEFT JOIN
+                       builds deprecated_builds ON builds.deprecated_by = deprecated_builds.id
+               WHERE
+                       builds.deleted_at IS NULL
+               AND
+                       deprecated_builds.deleted_at IS NULL
+               AND
+                       builds.deprecated_by IS NOT NULL
+
+               UNION ALL
+
                -- Build Comments
                SELECT
                        'build-comment' AS type,
                        build_comments.created_at AS t,
                        4 AS priority,
                        build_comments.build_id AS build,
+                       NULL AS by_build,
                        build_comments.id AS build_comment,
                        NULL AS user,
                        build_comments.user_id AS by_user
@@ -120,6 +150,7 @@ EVENTS_VIEW = """
                        build_watchers.added_at AS t,
                        1 AS priority,
                        build_watchers.build_id AS build,
+                       NULL AS by_build,
                        NULL AS build_comment,
                        build_watchers.user_id AS user,
                        NULL AS by_user
@@ -134,6 +165,7 @@ EVENTS_VIEW = """
                        build_watchers.deleted_at AS t,
                        1 AS priority,
                        build_watchers.build_id AS build,
+                       NULL AS by_build,
                        NULL AS build_comment,
                        build_watchers.user_id AS user,
                        NULL AS by_user
@@ -149,7 +181,8 @@ class Events(base.Object):
        def map(self):
                return {
                        # Builds
-                       "build" : self.backend.builds.get_by_id,
+                       "build"    : self.backend.builds.get_by_id,
+                       "by_build" : self.backend.builds.get_by_id,
 
                        # Build Comments
                        "build_comment" : self.backend.builds.comments.get_by_id,
index 41ed67d9e3d4a844f5ec751a7e18d2fecd6117b7..ac20f6cc48b0f394f02c33d4c13e1660f604c05c 100644 (file)
@@ -7,6 +7,8 @@
                                {{ _("Build Created") }}
                        {% elif event.type == "build-deleted" %}
                                {{ _("Build Deleted") }}
+                       {% elif event.type == "build-deprecated" %}
+                               {{ _("This build was deprecated") }}
                        {% elif event.type == "build-watcher-added" %}
                                {{ _("%s started watching this build") % event.user }}
                        {% elif event.type == "build-watcher-removed" %}
 
                <nav class="level">
                        <div class="level-left is-small">
+                               {# Build #}
                                {% if event.build %}
                                        <a class="level-item" href="/builds/{{ event.build.uuid }}">
                                                {{ event.build }}
                                        </a>
                                {% end %}
 
+                               {# By Build #}
+                               {% if event.by_build %}
+                                       <a class="level-item" href="/builds/{{ event.by_build.uuid }}">
+                                               {{ _("by %s") % event.by_build }}
+                                       </a>
+                               {% end %}
+
+                               {# By User #}
                                {% if event.by_user %}
                                        <a class="level-item" href="/users/{{ event.by_user.name }}">
                                                {{ _("by %s") % event.by_user }}