]> git.ipfire.org Git - pbs.git/commitdiff
builds: Move test builds view into code
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 7 Jun 2023 10:46:55 +0000 (10:46 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 7 Jun 2023 10:46:55 +0000 (10:46 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/database.sql

index e91b2ffb384b0f703993ebaae1e62f5aeda86179..f6f2e09b1872dabc50948fe64bc2f94d41337794 100644 (file)
@@ -28,6 +28,27 @@ class Builds(base.Object):
                for row in res:
                        yield Build(self.backend, row.id, data=row)
 
+       def init(self):
+               self.db.execute("""
+                       CREATE TEMPORARY VIEW build_test_builds AS (
+                               SELECT
+                                       builds.id AS build_id,
+                                       test_builds.id AS test_build_id
+                               FROM
+                                       builds
+                               JOIN
+                                       build_groups ON builds.test_group_id = build_groups.id
+                               JOIN
+                                       builds test_builds ON test_builds.build_group_id = build_groups.id
+                               WHERE
+                                       builds.deleted_at IS NULL
+                               AND
+                                       builds.test IS FALSE
+                               AND
+                                       build_groups.deleted_at IS NULL
+                       )
+               """)
+
        def __len__(self):
                res = self.db.get("""
                        SELECT
index 92976bfff9cd91d245de3fca71cf7accf337a250..90b63eaaa3192e6db56bf7c6c8b1f8467a834abb 100644 (file)
@@ -27,6 +27,52 @@ SET default_tablespace = '';
 
 SET default_table_access_method = heap;
 
+--
+-- Name: build_groups; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE public.build_groups (
+    id integer NOT NULL,
+    uuid uuid DEFAULT gen_random_uuid() NOT NULL,
+    created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
+    created_by integer,
+    deleted_at timestamp without time zone,
+    deleted_by integer,
+    finished_at timestamp without time zone,
+    failed boolean DEFAULT false NOT NULL,
+    tested_build_id integer
+);
+
+
+--
+-- Name: builds; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE public.builds (
+    id integer NOT NULL,
+    uuid uuid DEFAULT gen_random_uuid() NOT NULL,
+    pkg_id integer NOT NULL,
+    severity text,
+    message text,
+    created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
+    build_repo_id integer NOT NULL,
+    owner_id integer,
+    priority integer DEFAULT 0 NOT NULL,
+    finished_at timestamp without time zone,
+    failed boolean DEFAULT false NOT NULL,
+    deleted_at timestamp without time zone,
+    deleted_by integer,
+    build_group_id integer,
+    deprecating_build_id integer,
+    deprecated_at timestamp without time zone,
+    deprecated_by integer,
+    test_group_id integer,
+    test boolean DEFAULT false NOT NULL,
+    disable_test_builds boolean DEFAULT false NOT NULL,
+    points integer DEFAULT 0 NOT NULL
+);
+
+
 --
 -- Name: build_bugs; Type: TABLE; Schema: public; Owner: -
 --
@@ -56,23 +102,6 @@ CREATE TABLE public.build_comments (
 );
 
 
---
--- Name: build_groups; Type: TABLE; Schema: public; Owner: -
---
-
-CREATE TABLE public.build_groups (
-    id integer NOT NULL,
-    uuid uuid DEFAULT gen_random_uuid() NOT NULL,
-    created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
-    created_by integer,
-    deleted_at timestamp without time zone,
-    deleted_by integer,
-    finished_at timestamp without time zone,
-    failed boolean DEFAULT false NOT NULL,
-    tested_build_id integer
-);
-
-
 --
 -- Name: build_points; Type: TABLE; Schema: public; Owner: -
 --
@@ -126,35 +155,6 @@ CREATE TABLE public.builders (
 );
 
 
---
--- Name: builds; Type: TABLE; Schema: public; Owner: -
---
-
-CREATE TABLE public.builds (
-    id integer NOT NULL,
-    uuid uuid DEFAULT gen_random_uuid() NOT NULL,
-    pkg_id integer NOT NULL,
-    severity text,
-    message text,
-    created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
-    build_repo_id integer NOT NULL,
-    owner_id integer,
-    priority integer DEFAULT 0 NOT NULL,
-    finished_at timestamp without time zone,
-    failed boolean DEFAULT false NOT NULL,
-    deleted_at timestamp without time zone,
-    deleted_by integer,
-    build_group_id integer,
-    deprecating_build_id integer,
-    deprecated_at timestamp without time zone,
-    deprecated_by integer,
-    test_group_id integer,
-    test boolean DEFAULT false NOT NULL,
-    disable_test_builds boolean DEFAULT false NOT NULL,
-    points integer DEFAULT 0 NOT NULL
-);
-
-
 --
 -- Name: jobs; Type: TABLE; Schema: public; Owner: -
 --
@@ -376,19 +376,6 @@ CREATE TABLE public.build_packages (
 );
 
 
---
--- Name: build_test_builds; Type: VIEW; Schema: public; Owner: -
---
-
-CREATE VIEW public.build_test_builds AS
- SELECT builds.id AS build_id,
-    test_builds.id AS test_build_id
-   FROM ((public.builds
-     JOIN public.build_groups ON ((builds.test_group_id = build_groups.id)))
-     JOIN public.builds test_builds ON ((test_builds.build_group_id = build_groups.id)))
-  WHERE ((builds.deleted_at IS NULL) AND (build_groups.deleted_at IS NULL));
-
-
 --
 -- Name: builder_stats; Type: TABLE; Schema: public; Owner: -
 --