for row in res:
yield Job(self.backend, row.id, data=row)
- def create(self, build, arch, type="build", superseeds=None):
- job = self._get_job("INSERT INTO jobs(uuid, type, build_id, arch, time_created) \
- VALUES(%s, %s, %s, %s, NOW()) RETURNING *", "%s" % uuid.uuid4(), type, build.id, arch)
+ def create(self, build, arch, test=False superseeds=None):
+ job = self._get_job("INSERT INTO jobs(uuid, build_id, arch, test) \
+ VALUES(%s, %s, %s, %s) RETURNING *", "%s" % uuid.uuid4(), build.id, arch, test)
job.log("created")
# Set cache for Build object.
# Restart the job
for job in jobs:
- job.set_state("new", log=False)
+ job.restart()
class Job(base.DataObject):
def distro(self):
return self.build.distro
+ def restart(self):
+ # Copy the job and let it build again
+ return self.backend.jobs.create(self.build, self.arch,
+ test=self.test, superseeds=self)
+
def get_superseeded_by(self):
if self.data.superseeded_by:
return self.backend.jobs.get_by_id(self.data.superseeded_by)
if self.state == "finished":
return
- self.set_state("new", user=user, log=False)
- self.set_start_time(start_time)
+ job = self.restart()
+ job.set_start_time(start_time)
# Log the event.
self.log("schedule_rebuild", user=user)
return
# Create a new job with same build and arch.
- job = self.create(self.backend, self.build, self.arch, type="test")
+ job = self.create(self.backend, self.build, self.arch, test=True)
job.set_start_time(start_time)
# Log the event.
build_id integer NOT NULL,
state jobs_state DEFAULT 'new'::jobs_state NOT NULL,
arch text NOT NULL,
- time_created timestamp without time zone NOT NULL,
+ time_created timestamp without time zone DEFAULT now() NOT NULL,
time_started timestamp without time zone,
time_finished timestamp without time zone,
start_not_before timestamp without time zone,