]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
jobs: Drop type field and replace it by test field
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 Oct 2017 13:49:49 +0000 (14:49 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 Oct 2017 13:49:49 +0000 (14:49 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builders.py
src/buildservice/builds.py
src/buildservice/jobs.py
src/database.sql
src/hub/handlers.py
src/scripts/pakfire-build-service
src/templates/modules/jobs/list.html
src/web/handlers_packages.py

index 089c1c0144dfb9c0989306ffa6e301952eec541b..fef7b9fa90cbe67140172bd842de00e8ee8a8c10 100644 (file)
@@ -394,7 +394,7 @@ class Builder(base.DataObject):
 
                for job in self.jobqueue:
                        # Only allow building test jobs in test mode
-                       if self.testmode and not job.type == "test":
+                       if self.testmode and not job.test:
                                continue
 
                        return job
index 281dce80b784d36f6eddeccfa3974afcd6822841..e5343afcbde2fed10e8b8f2865b704f7b6c2f658 100644 (file)
@@ -356,7 +356,7 @@ class Builds(base.Object):
 
                return comments
 
-       def get_build_times_summary(self, name=None, job_type=None, arch=None):
+       def get_build_times_summary(self, name=None, arch=None):
                query = "\
                        SELECT \
                                builds_times.arch AS arch, \
@@ -377,11 +377,6 @@ class Builds(base.Object):
                        conditions.append("packages.name = %s")
                        args.append(name)
 
-               # Filter by job types.
-               if job_type:
-                       conditions.append("builds_times.job_type = %s")
-                       args.append(job_type)
-
                # Filter by arch.
                if arch:
                        conditions.append("builds_times.arch = %s")
index f60f44d2498a95fc2c9fddc346799329b512698d..62effd5ca2e1b39fa5d3f85eb8eb1cce4d91dbba 100644 (file)
@@ -210,7 +210,7 @@ class Job(base.DataObject):
 
        def __lt__(self, other):
                if isinstance(other, self.__class__):
-                       if (self.type, other.type) == ("build", "test"):
+                       if not self.test and other.test:
                                return True
 
                        if self.build == other.build:
@@ -347,8 +347,8 @@ class Job(base.DataObject):
                return self.data.uuid
 
        @property
-       def type(self):
-               return self.data.type
+       def test(self):
+               return self.data.test
 
        @property
        def build_id(self):
@@ -445,7 +445,7 @@ class Job(base.DataObject):
                                self.send_failed_message()
 
                # Automatically update the state of the build (not on test builds).
-               if self.type == "build":
+               if not self.test:
                        self.build.auto_update_state()
 
        state = property(get_state, set_state)
@@ -570,7 +570,7 @@ class Job(base.DataObject):
 
                elif filename.endswith(".%s" % PACKAGE_EXTENSION):
                        # It is not allowed to upload packages on test builds.
-                       if self.type == "test":
+                       if self.test:
                                return
 
                        self._add_file_package(filename)
@@ -581,7 +581,7 @@ class Job(base.DataObject):
                """
                target_dirname = os.path.join(self.build.path, "logs")
 
-               if self.type == "test":
+               if self.test:
                        i = 1
                        while True:
                                target_filename = os.path.join(target_dirname,
@@ -707,7 +707,7 @@ class Job(base.DataObject):
 
        def send_finished_message(self):
                # Send no finished mails for test jobs.
-               if self.type == "test":
+               if self.test:
                        return
 
                logging.debug("Sending finished message for job %s to %s" % \
index 03d24015dec5cf84b6aad33e3542c36fe0c27c4a..bf5327759c60d1a4f275cc9878671a46ddfe711a 100644 (file)
@@ -663,15 +663,15 @@ CREATE TABLE builds (
     state text DEFAULT 'building'::text NOT NULL,
     severity builds_severity,
     message text,
-    time_created timestamp without time zone NOT NULL,
+    time_created timestamp without time zone DEFAULT now() NOT NULL,
     update_year integer,
     update_num integer,
     depends_on integer,
     distro_id integer NOT NULL,
     owner_id integer,
-    public builds_public DEFAULT 'Y'::builds_public NOT NULL,
+    public boolean DEFAULT true NOT NULL,
     priority integer DEFAULT 0 NOT NULL,
-    auto_move builds_auto_move DEFAULT 'N'::builds_auto_move NOT NULL
+    auto_move boolean DEFAULT false NOT NULL
 );
 
 
@@ -864,7 +864,10 @@ CREATE TABLE jobs (
     builder_id integer,
     tries integer DEFAULT 0 NOT NULL,
     aborted_state integer DEFAULT 0 NOT NULL,
-    message text
+    message text,
+    test boolean DEFAULT true NOT NULL,
+    superseeded_by integer,
+    deleted boolean DEFAULT false NOT NULL
 );
 
 
@@ -875,13 +878,11 @@ ALTER TABLE jobs OWNER TO pakfire;
 --
 
 CREATE VIEW builds_times AS
- SELECT builds.id AS build_id,
+ SELECT jobs.build_id,
     jobs.arch,
-    jobs.type AS job_type,
     (jobs.time_finished - jobs.time_started) AS duration
-   FROM (jobs
-     LEFT JOIN builds ON ((jobs.build_id = builds.id)))
-  WHERE (jobs.state = 'finished'::jobs_state);
+   FROM jobs
+  WHERE (((jobs.deleted IS FALSE) AND (jobs.test IS FALSE)) AND (jobs.state = 'finished'::jobs_state));
 
 
 ALTER TABLE builds_times OWNER TO pakfire;
@@ -1004,7 +1005,7 @@ CREATE TABLE filelists (
     size bigint NOT NULL,
     hash_sha512 text,
     type integer NOT NULL,
-    config filelists_config NOT NULL,
+    config boolean NOT NULL,
     mode integer NOT NULL,
     "user" text NOT NULL,
     "group" text NOT NULL,
@@ -1055,7 +1056,6 @@ ALTER SEQUENCE images_types_id_seq OWNED BY images_types.id;
 CREATE VIEW jobs_active AS
  SELECT jobs.id,
     jobs.uuid,
-    jobs.type,
     jobs.build_id,
     jobs.state,
     jobs.arch,
@@ -2738,13 +2738,6 @@ CREATE INDEX idx_2198063_state ON jobs USING btree (state);
 CREATE INDEX idx_2198063_time_finished ON jobs USING btree (time_finished);
 
 
---
--- Name: idx_2198063_type; Type: INDEX; Schema: public; Owner: pakfire; Tablespace: 
---
-
-CREATE INDEX idx_2198063_type ON jobs USING btree (type);
-
-
 --
 -- Name: idx_2198063_uuid; Type: INDEX; Schema: public; Owner: pakfire; Tablespace: 
 --
@@ -2892,6 +2885,13 @@ CREATE INDEX jobs_arch ON jobs USING btree (arch);
 CREATE INDEX jobs_buildroots_pkg_uuid ON jobs_buildroots USING btree (pkg_uuid);
 
 
+--
+-- Name: jobs_type; Type: INDEX; Schema: public; Owner: pakfire; Tablespace: 
+--
+
+CREATE INDEX jobs_type ON jobs USING btree (test) WHERE (deleted IS FALSE);
+
+
 --
 -- Name: mirrors_checks_sort; Type: INDEX; Schema: public; Owner: pakfire; Tablespace: 
 --
index a117bde6a5982cd863b776011a977615b675f8ab..0f63b65ea1ad8af9929cea59581a58b3e64740ac 100644 (file)
@@ -340,7 +340,7 @@ class JobsBaseHandler(BaseHandler):
                        "packages"     : [p.uuid for p in job.packages],
                        "state"        : job.state,
                        "time_created" : job.time_created.isoformat(),
-                       "type"         : job.type,
+                       "type"         : "test" if job.test else "release",
                        "uuid"         : job.uuid,
                }
 
@@ -564,7 +564,7 @@ class BuildersJobsQueueHandler(BuildersBaseHandler):
                                "arch"               : job.arch,
                                "source_url"         : job.build.source_download,
                                "source_hash_sha512" : job.build.source_hash_sha512,
-                               "type"               : job.type,
+                               "type"               : "test" if job.test else "release",
                                "config"             : job.get_config(),
                        }
 
index c757a74eb6ad3a5e0d0f1fff7a02dbb1260d165c..1f2a086cbef8fd56af8db59ddb2acb135f23f315 100644 (file)
@@ -92,7 +92,8 @@ class Cli(object):
                # Iterate through all of it
                for build in repo:
                        for job in build:
-                               if not job.type == "build":
+                               # Skip all test jobs
+                               if job.test:
                                        continue
 
                                if not job.arch in (arch, "noarch"):
index cdc65a7a56fa704e38b309fe3557bf881fac34fe..cdb33f17cd528551728e5e60af57eac6413062d5 100644 (file)
@@ -30,7 +30,7 @@
 
                                        {% if job.build.type == "scratch" %}
                                                <span class="label label-inverse pull-right" rel="tooltip" data-placement="top" title="{{ _("Scratch build") }}">S</span>
-                                       {% elif job.type == "test" %}
+                                       {% elif job.test %}
                                                <span class="label label-inverse pull-right" rel="tooltip" data-placement="top" title="{{ _("Test build") }}">T</span>
                                        {% end %}
                                </td>
index d108360a914bcf25b66ee84a5ae928b0309f0ff3..b4be18d8c18238bc2c6f2c66b1d7de542e9fbec2 100644 (file)
@@ -253,8 +253,7 @@ class PackageBuildsTimesHandler(BaseHandler):
                        raise tornado.web.HTTPError(404)
 
                # Get the summary stats.
-               build_times_summary = self.pakfire.builds.get_build_times_summary(name,
-                       job_type="build")
+               build_times_summary = self.pakfire.builds.get_build_times_summary(name)
 
                self.render("packages/builds/times.html", pkg=latest_build.pkg,
                        build_times_summary=build_times_summary)