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
# Filter by build
if build:
- conditions.append("build_id = %s")
+ conditions.append("build = %s")
values.append(build)
# Filter by priority