From: Michael Tremer Date: Thu, 13 Oct 2022 10:01:16 +0000 (+0000) Subject: events: Reorder the view to make it easier to extend X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=76385b24201b9999ef3a1d0693210f0771fd6be3;p=pbs.git events: Reorder the view to make it easier to extend Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/events.py b/src/buildservice/events.py index 24673d66..10251206 100644 --- a/src/buildservice/events.py +++ b/src/buildservice/events.py @@ -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