From b23e184a61fde52b256146c7acf804a4441ae580 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 20 Sep 2023 16:02:32 +0000 Subject: [PATCH] events: Show when builds are moving repository This keeps the event log shorter and makes it clearer what has happened. Signed-off-by: Michael Tremer --- src/buildservice/events.py | 33 +++++++++++++++++-- .../events/modules/system-message.html | 6 ++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/buildservice/events.py b/src/buildservice/events.py index 163a0b07..886ea4db 100644 --- a/src/buildservice/events.py +++ b/src/buildservice/events.py @@ -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 diff --git a/src/templates/events/modules/system-message.html b/src/templates/events/modules/system-message.html index 014f9b33..382320b3 100644 --- a/src/templates/events/modules/system-message.html +++ b/src/templates/events/modules/system-message.html @@ -53,6 +53,10 @@

+ {% elif event.type == "repository-build-moved" %} +

+ +

{% elif event.type == "repository-build-removed" %}

@@ -168,6 +172,8 @@ {{ _("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" %} -- 2.47.3