From 8f04a9e99994cf933ce9041b700aa3a3679f1a27 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 21 Oct 2017 16:08:44 +0100 Subject: [PATCH] jobs: Remove deps to type field Signed-off-by: Michael Tremer --- src/buildservice/builds.py | 22 +++++++++------------- src/buildservice/jobs.py | 26 -------------------------- 2 files changed, 9 insertions(+), 39 deletions(-) diff --git a/src/buildservice/builds.py b/src/buildservice/builds.py index 36634f5..eed8420 100644 --- a/src/buildservice/builds.py +++ b/src/buildservice/builds.py @@ -762,7 +762,7 @@ class Build(base.DataObject): s_jobs = [] for job in self.jobs: s_jobs.append("""%s""" % \ - (job.state, job.type, job.uuid, job.arch)) + (job.state, "test" if job.test else "build", job.uuid, job.arch)) if s_jobs: s += " [%s]" % ", ".join(s_jobs) @@ -777,22 +777,18 @@ class Build(base.DataObject): def critical_path(self): return self.pkg.critical_path - def get_jobs(self, type=None): - """ - Returns a list of jobs of this build. - """ - return self.backend.jobs.get_by_build(self.id, self, type=type) - @lazy_property def jobs(self): """ Get a list of all build jobs that are in this build. """ - return self.get_jobs(type="build") + return self.backend.jobs._get_jobs("SELECT * FROM jobs \ + WHERE build_id = %s AND test IS FALSE AND deleted_at IS NULL", self.id) @property def test_jobs(self): - return self.get_jobs(type="test") + return self.backend.jobs._get_jobs("SELECT * FROM jobs \ + WHERE build_id = %s AND test IS TRUE AND deleted_at IS NULL", self.id) @property def all_jobs_finished(self): @@ -805,7 +801,7 @@ class Build(base.DataObject): return ret - def create_autojobs(self, arches=None, type="build"): + def create_autojobs(self, arches=None, **kwargs): jobs = [] # Arches may be passed to this function. If not we use all arches @@ -819,14 +815,14 @@ class Build(base.DataObject): if arch == "src": continue - job = self.add_job(arch, type=type) + job = self.add_job(arch, **kwargs) jobs.append(job) # Return all newly created jobs. return jobs - def add_job(self, arch, type="build"): - job = self.backend.jobs.create(self, arch, type=type) + def add_job(self, arch, **kwargs): + job = self.backend.jobs.create(self, arch, **kwargs) # Add new job to cache. self.jobs.append(job) diff --git a/src/buildservice/jobs.py b/src/buildservice/jobs.py index c875378..aac3f41 100644 --- a/src/buildservice/jobs.py +++ b/src/buildservice/jobs.py @@ -63,32 +63,6 @@ class Jobs(base.Object): if job: return self.get_by_id(job.id) - def get_by_build(self, build_id, build=None, type=None): - """ - Get all jobs in the specifies build. - """ - query = "SELECT * FROM jobs WHERE build_id = %s" - args = [build_id,] - - if type: - query += " AND type = %s" - args.append(type) - - # Get IDs of all builds in this group. - jobs = [] - for job in self.db.query(query, *args): - job = Job(self.backend, job.id, job) - - # If the Build object was set, we set it so it won't be retrieved - # from the database again. - if build: - job._build = build - - jobs.append(job) - - # Return sorted list of jobs. - return sorted(jobs) - def get_active(self, host_id=None, builder=None, states=None): if builder: host_id = builder.id -- 2.47.3