]> git.ipfire.org Git - pbs.git/commitdiff
events: Reorder the view to make it easier to extend
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 13 Oct 2022 10:01:16 +0000 (10:01 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 13 Oct 2022 10:01:16 +0000 (10:01 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/events.py

index 24673d6614745fb9f3c91a7e7ddb9894582f5db5..102512069846f12b8f2f0d79ce3479b3515bd337 100644 (file)
@@ -27,28 +27,48 @@ from .decorators import *
 
 log = logging.getLogger("pakfire.buildservice.events")
 
+# Priorities (the higher, the more important)
+# ERROR          : 10
+# WARNING        : 8
+# MAJOR INFO     : 5
+# MINOR INFO     : 4
+# DEBUG          : 0
+
+# The view returns the following fields
+# type (of the event)
+# t (timestamp)
+# priority
+# build
+# by_user
+#
 EVENTS_VIEW = """
        WITH events AS (
                -- Build creation times
                SELECT
-                       builds.id AS build_id,
-                       builds.created_at AS t,
                        'build-created'::text AS type,
+                       builds.created_at AS t,
+                       4 AS priority,
+                       builds.id AS build,
                        builds.owner_id AS by_user
                FROM
                        builds
 
-               -- Build finish/failed times
                UNION ALL
 
+               -- Build finish/failed times
                SELECT
-                       builds.id AS build_id,
-                       builds.finished_at AS t,
                        CASE
                                WHEN builds.failed IS TRUE
                                THEN 'build-failed'::text
                                ELSE 'build-finished'::text
                        END AS type,
+                       builds.finished_at AS t,
+                       CASE
+                               WHEN builds.failed IS TRUE
+                               THEN 8
+                               ELSE 4
+                       END AS priority,
+                       builds.id AS build,
                        NULL AS by_user
                FROM
                        builds
@@ -118,7 +138,7 @@ class Events(base.Object):
 
                # Filter by build
                if build:
-                       conditions.append("build_id = %s")
+                       conditions.append("build = %s")
                        values.append(build)
 
                # Filter by priority