]> git.ipfire.org Git - pbs.git/commitdiff
events: Add points to the log
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 May 2023 21:10:21 +0000 (21:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 12 May 2023 21:10:21 +0000 (21:10 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/events.py
src/templates/events/modules/system-message.html

index d9149ac7b84c38454ebffabbc6775c3d0a761e65..2e37543aaf6f0cb11570541cc9cb30a5669f37f3 100644 (file)
@@ -46,6 +46,7 @@ log = logging.getLogger("pbs.events")
 # by_user
 # builder
 # repository
+# points
 #
 EVENTS_VIEW = """
        WITH events AS (
@@ -61,7 +62,8 @@ EVENTS_VIEW = """
                        NULL::integer AS user,
                        builds.owner_id AS by_user,
                        NULL::integer AS builder,
-                       NULL::integer AS repository
+                       NULL::integer AS repository,
+                       NULL::integer AS points
                FROM
                        builds
 
@@ -87,7 +89,8 @@ EVENTS_VIEW = """
                        NULL AS user,
                        NULL AS by_user,
                        NULL AS builder,
-                       NULL AS repository
+                       NULL AS repository,
+                       NULL AS points
                FROM
                        builds
                WHERE
@@ -107,7 +110,8 @@ EVENTS_VIEW = """
                        NULL AS user,
                        builds.deleted_by AS by_user,
                        NULL AS builder,
-                       NULL AS repository
+                       NULL AS repository,
+                       NULL AS points
                FROM
                        builds
                WHERE
@@ -128,7 +132,8 @@ EVENTS_VIEW = """
                        NULL AS user,
                        builds.deprecated_by AS by_user,
                        NULL AS builder,
-                       NULL AS repository
+                       NULL AS repository,
+                       NULL AS points
                FROM
                        builds
                WHERE
@@ -150,7 +155,8 @@ EVENTS_VIEW = """
                        NULL AS user,
                        build_comments.user_id AS by_user,
                        NULL AS builder,
-                       NULL AS repository
+                       NULL AS repository,
+                       NULL AS points
                FROM
                        build_comments
                WHERE
@@ -170,7 +176,8 @@ EVENTS_VIEW = """
                        build_watchers.user_id AS user,
                        NULL AS by_user,
                        NULL AS builder,
-                       NULL AS repository
+                       NULL AS repository,
+                       NULL AS points
                FROM
                        build_watchers
 
@@ -188,7 +195,8 @@ EVENTS_VIEW = """
                        build_watchers.user_id AS user,
                        NULL AS by_user,
                        NULL AS builder,
-                       NULL AS repository
+                       NULL AS repository,
+                       NULL AS points
                FROM
                        build_watchers
                WHERE
@@ -208,7 +216,8 @@ EVENTS_VIEW = """
                        NULL AS user,
                        repository_builds.added_by AS by_user,
                        NULL AS builder,
-                       repository_builds.repo_id AS repository
+                       repository_builds.repo_id AS repository,
+                       NULL AS points
                FROM
                        repository_builds
 
@@ -226,7 +235,8 @@ EVENTS_VIEW = """
                        NULL AS user,
                        repository_builds.removed_by AS by_user,
                        NULL AS builder,
-                       repository_builds.repo_id AS repository
+                       repository_builds.repo_id AS repository,
+                       NULL AS points
                FROM
                        repository_builds
                WHERE
@@ -234,6 +244,26 @@ EVENTS_VIEW = """
 
                UNION ALL
 
+               -- Build Scores
+
+               SELECT
+                       'build-points' AS type,
+                       build_points.created_at AS t,
+                       1 AS priority,
+                       build_points.build_id AS build,
+                       NULL AS by_build,
+                       NULL AS build_comment,
+                       NULL AS job,
+                       NULL AS user,
+                       build_points.user_id AS by_user,
+                       NULL AS builder,
+                       NULL AS repository,
+                       build_points.points AS points
+               FROM
+                       build_points
+
+               UNION ALL
+
                -- Jobs Creations
                SELECT
                        'job-created' AS type,
@@ -246,7 +276,8 @@ EVENTS_VIEW = """
                        NULL AS user,
                        NULL AS by_user,
                        NULL AS builder,
-                       NULL AS repository
+                       NULL AS repository,
+                       NULL AS points
                FROM
                        jobs
                WHERE
@@ -266,7 +297,8 @@ EVENTS_VIEW = """
                        NULL AS user,
                        NULL AS by_user,
                        jobs.builder_id AS builder,
-                       NULL AS repository
+                       NULL AS repository,
+                       NULL AS points
                FROM
                        jobs
                WHERE
@@ -292,7 +324,8 @@ EVENTS_VIEW = """
                        NULL AS user,
                        NULL AS by_user,
                        jobs.builder_id AS builder,
-                       NULL AS repository
+                       NULL AS repository,
+                       NULL AS points
                FROM
                        jobs
                WHERE
@@ -318,7 +351,8 @@ EVENTS_VIEW = """
                        NULL AS user,
                        jobs.aborted_by AS by_user,
                        jobs.builder_id AS builder,
-                       NULL AS repository
+                       NULL AS repository,
+                       NULL AS points
                FROM
                        jobs
                WHERE
@@ -340,7 +374,8 @@ EVENTS_VIEW = """
                        NULL AS user,
                        NULL AS by_user,
                        jobs.builder_id AS builder,
-                       NULL AS repository
+                       NULL AS repository,
+                       NULL AS points
                FROM
                        jobs
                WHERE
@@ -362,7 +397,8 @@ EVENTS_VIEW = """
                        NULL AS user,
                        NULL AS by_user,
                        NULL AS builder,
-                       NULL AS repository
+                       NULL AS repository,
+                       NULL AS points
                FROM
                        jobs
                JOIN
index fcf2f2173b4c35b911385e3c68a39489bc9b4c84..cc72a7a5f0e86fc9c6e7736fa95f09a6757f185e 100644 (file)
                                <p class="icon is-large has-text-danger">
                                        <i class="fa-solid fa-2x fa-xmark"></i>
                                </p>
+                       {% elif event.type == "build-points" and event.points > 0 %}
+                               <p class="icon is-large has-text-success">
+                                       <i class="fa-solid fa-2x fa-thumbs-up"></i>
+                               </p>
+                       {% elif event.type == "build-points" and event.points < 0 %}
+                               <p class="icon is-large has-text-danger">
+                                       <i class="fa-solid fa-2x fa-thumbs-down"></i>
+                               </p>
                        {% else %}
                                <p class="icon is-large has-text-light">
                                        <i class="fa-solid fa-2x fa-question"></i>
                                        {{ _("%s started watching this build") % event.user }}
                                {% elif event.type == "build-watcher-removed" %}
                                        {{ _("%s stopped watching this build") % event.user }}
+                               {% elif event.type == "build-points" %}
+                                       {% if event.points > 0 %}
+                                               {{ _("This build has gained one point", "This build has gained %(points)s points", event.points) % { "points" : event.points } }}
+                                       {% elif event.points < 0 %}
+                                               {{ _("This build has lost one point", "This build has lost %(points)s points", -event.points) % { "points" : -event.points } }}
+                                       {% end %}
                                {% elif event.type == "job-created" %}
                                        {{ _("Job Created") }}
                                {% elif event.type == "job-failed" %}