]> git.ipfire.org Git - people/jschlag/pbs.git/commitdiff
jobs: Remove deps to type field
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 Oct 2017 15:08:44 +0000 (16:08 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 21 Oct 2017 15:08:44 +0000 (16:08 +0100)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/buildservice/builds.py
src/buildservice/jobs.py

index 36634f5b8a6ff1861a2f0f512e4647e796aedf6c..eed842086f11af64610a6ba2f2edd12f342c7163 100644 (file)
@@ -762,7 +762,7 @@ class Build(base.DataObject):
                s_jobs = []
                for job in self.jobs:
                        s_jobs.append("""<a class="state_%s %s" href="/job/%s">%s</a>""" % \
-                               (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)
index c87537894870e95751c4cec7e347dced00b13f4f..aac3f41a7b09d5e3f3e239640a9c447af7b8cbc3 100644 (file)
@@ -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