From: Michael Tremer Date: Sat, 21 Oct 2017 13:49:49 +0000 (+0100) Subject: jobs: Drop type field and replace it by test field X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f90cf84300c598cbbfc35e89e4905a4733c29b1;p=people%2Fjschlag%2Fpbs.git jobs: Drop type field and replace it by test field Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/builders.py b/src/buildservice/builders.py index 089c1c0..fef7b9f 100644 --- a/src/buildservice/builders.py +++ b/src/buildservice/builders.py @@ -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 diff --git a/src/buildservice/builds.py b/src/buildservice/builds.py index 281dce8..e5343af 100644 --- a/src/buildservice/builds.py +++ b/src/buildservice/builds.py @@ -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") diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index f60f44d..62effd5 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -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" % \ diff --git a/src/database.sql b/src/database.sql index 03d2401..bf53277 100644 --- a/src/database.sql +++ b/src/database.sql @@ -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: -- diff --git a/src/hub/handlers.py b/src/hub/handlers.py index a117bde..0f63b65 100644 --- a/src/hub/handlers.py +++ b/src/hub/handlers.py @@ -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(), } diff --git a/src/scripts/pakfire-build-service b/src/scripts/pakfire-build-service index c757a74..1f2a086 100644 --- a/src/scripts/pakfire-build-service +++ b/src/scripts/pakfire-build-service @@ -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"): diff --git a/src/templates/modules/jobs/list.html b/src/templates/modules/jobs/list.html index cdc65a7..cdb33f1 100644 --- a/src/templates/modules/jobs/list.html +++ b/src/templates/modules/jobs/list.html @@ -30,7 +30,7 @@ {% if job.build.type == "scratch" %} S - {% elif job.type == "test" %} + {% elif job.test %} T {% end %} diff --git a/src/web/handlers_packages.py b/src/web/handlers_packages.py index d108360..b4be18d 100644 --- a/src/web/handlers_packages.py +++ b/src/web/handlers_packages.py @@ -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)