]> git.ipfire.org Git - pbs.git/commitdiff
events: Show when builds are moving repository
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 20 Sep 2023 16:02:32 +0000 (16:02 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 20 Sep 2023 16:02:32 +0000 (16:02 +0000)
This keeps the event log shorter and makes it clearer what has happened.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/events.py
src/templates/events/modules/system-message.html

index 163a0b0728fa30446c00e0135f58d03602d66665..886ea4db1fb8bd39e024b2de7ad2f2cbea489e6e 100644 (file)
@@ -306,9 +306,14 @@ EVENTS_CTE = """
 
                UNION ALL
 
-               -- Build added to repository
+               -- Build added to/moved repository
                SELECT
-                       'repository-build-added' AS type,
+                       CASE
+                               WHEN source_repo.repo_id IS NULL
+                                       THEN 'repository-build-added'
+                               ELSE
+                                       'repository-build-moved'
+                       END AS type,
                        repository_builds.added_at AS t,
                        5 AS priority,
                        repository_builds.build_id AS build,
@@ -329,6 +334,16 @@ EVENTS_CTE = """
                FROM
                        repository_builds
 
+               -- Attempt to find a match in a source repository
+               LEFT JOIN
+                       repository_builds source_repo
+               ON
+                       repository_builds.build_id = source_repo.build_id
+               AND
+                       repository_builds.repo_id <> source_repo.repo_id
+               AND
+                       repository_builds.added_at = source_repo.removed_at
+
                UNION ALL
 
                -- Build removed from repository
@@ -353,8 +368,20 @@ EVENTS_CTE = """
                        NULL AS points
                FROM
                        repository_builds
+
+               -- Attempt to find a match in a destination repository
+               LEFT JOIN
+                       repository_builds destination_repo
+               ON
+                       repository_builds.build_id = destination_repo.build_id
+               AND
+                       repository_builds.repo_id <> destination_repo.repo_id
+               AND
+                       repository_builds.removed_at = destination_repo.added_at
                WHERE
-                       removed_at IS NOT NULL
+                       repository_builds.removed_at IS NOT NULL
+               AND
+                       destination_repo.repo_id IS NULL
 
                UNION ALL
 
index 014f9b331c23c166e9e44906e2ea3350e41c7bb2..382320b371562b983ef6dbd969621f29d9acf4e5 100644 (file)
                                <p class="icon is-large has-text-success">
                                        <i class="fa-solid fa-2x fa-circle-plus"></i>
                                </p>
+                       {% elif event.type == "repository-build-moved" %}
+                               <p class="icon is-large has-text-success">
+                                       <i class="fa-solid fa-2x fa-circle-plus"></i>
+                               </p>
                        {% elif event.type == "repository-build-removed" %}
                                <p class="icon is-large has-text-danger">
                                        <i class="fa-solid fa-2x fa-circle-minus"></i>
                                        {{ _("Mirror Went Offline") }}
                                {% elif event.type == "repository-build-added" %}
                                        {{ _("Build has been added to repository %s") % event.repository }}
+                               {% elif event.type == "repository-build-moved" %}
+                                       {{ _("Build has been moved to repository %s") % event.repository }}
                                {% elif event.type == "repository-build-removed" %}
                                        {{ _("Build has been removed from repository %s") % event.repository }}
                                {% elif event.type == "release-monitoring-created" %}