def delete(self):
"""
- Deletes this build including all jobs, packages and the source
- package.
+ Deletes this build including all jobs,
+ packages and the source package.
"""
# If the build is in a repository, we need to remove it.
if self.repo:
self.repo.rem_build(self)
- for job in self.jobs + self.test_jobs:
+ # Delete all release jobs
+ for job in self.jobs:
job.delete()
- if self.pkg:
- self.pkg.delete()
-
- # Delete everything related to this build.
- self.__delete_bugs()
- self.__delete_comments()
- self.__delete_history()
- self.__delete_watchers()
-
- # Delete the build itself.
- self.db.execute("DELETE FROM builds WHERE id = %s", self.id)
+ # Delete all test jobs
+ for job in self.test_jobs:
+ job.delete()
- def __delete_bugs(self):
- """
- Delete all associated bugs.
- """
+ # Deleted all associated bugs
self.db.execute("DELETE FROM builds_bugs WHERE build_id = %s", self.id)
- def __delete_comments(self):
- """
- Delete all comments.
- """
+ # Delete all comments
self.db.execute("DELETE FROM builds_comments WHERE build_id = %s", self.id)
- def __delete_history(self):
- """
- Delete the repository history.
- """
+ # Delete the repository history
self.db.execute("DELETE FROM repositories_history WHERE build_id = %s", self.id)
- def __delete_watchers(self):
- """
- Delete all watchers.
- """
+ # Delete all watchers
self.db.execute("DELETE FROM builds_watchers WHERE build_id = %s", self.id)
+ # Delete build history
+ self.db.execute("DELETE FROM builds_history WHERE build_id = %s", self.id)
+
+ # Delete the build itself.
+ self.db.execute("DELETE FROM builds WHERE id = %s", self.id)
+
+ # Delete source package
+ self.pkg.delete()
+
@property
def info(self):
"""
Get a list of all build jobs that are in this build.
"""
return self._get_jobs("SELECT * FROM jobs \
- WHERE build_id = %s AND test IS FALSE AND deleted_at IS NULL", self.id)
+ WHERE build_id = %s AND test IS FALSE", self.id)
@property
def test_jobs(self):
return self._get_jobs("SELECT * FROM jobs \
- WHERE build_id = %s AND test IS TRUE AND deleted_at IS NULL", self.id)
+ WHERE build_id = %s AND test IS TRUE", self.id)
@property
def all_jobs_finished(self):
superseeded_by = lazy_property(get_superseeded_by, set_superseeded_by)
def delete(self):
- self._set_attribute("delete", True)
-
- def remove(self):
- """
- Removes a job from the database
- """
- self.__remove_buildroots()
- self.__remove_history()
- self.__remove_packages()
- self.__remove_logfiles()
-
- # Delete the job itself.
- self.db.execute("DELETE FROM jobs WHERE id = %s", self.id)
-
- def __remove_buildroots(self):
"""
- Removes all buildroots.
+ Deletes a job from the database
"""
+ # Remove the buildroot
self.db.execute("DELETE FROM jobs_buildroots WHERE job_id = %s", self.id)
- def __remove_history(self):
- """
- Removes all references in the history to this build job.
- """
+ # Remove the history
self.db.execute("DELETE FROM jobs_history WHERE job_id = %s", self.id)
- def __remove_packages(self):
- """
- Deletes all uploaded files from the job.
- """
- for pkg in self.packages:
+ # Delete all packages
+ for pkg in self:
+ self.db.execute("DELETE FROM jobs_packages \
+ WHERE job_id = %s AND pkg_id = %s", self.id, pkg.id)
pkg.delete()
- self.db.execute("DELETE FROM jobs_packages WHERE job_id = %s", self.id)
-
- def __remove_logfiles(self):
+ # Remove all logfiles
for logfile in self.logfiles:
self.db.execute("INSERT INTO queue_delete(path) VALUES(%s)", logfile.path)
+ self.db.execute("DELETE FROM logfiles WHERE job_id = %s", self.id)
+
+ # Delete the job itself.
+ self.db.execute("DELETE FROM jobs WHERE id = %s", self.id)
+
## Logging stuff
def log(self, action, user=None, state=None, builder=None, test_job=None):
aborted_state integer DEFAULT 0 NOT NULL,
message text,
test boolean DEFAULT true NOT NULL,
- superseeded_by integer,
- deleted_at timestamp without time zone
+ superseeded_by integer
);
jobs.arch,
(jobs.time_finished - jobs.time_started) AS duration
FROM jobs
- WHERE (((jobs.deleted_at IS NULL) AND (jobs.test IS FALSE)) AND (jobs.state = 'finished'::jobs_state));
+ WHERE ((jobs.test IS FALSE) AND (jobs.state = 'finished'::jobs_state));
ALTER TABLE builds_times OWNER TO pakfire;
CREATE INDEX jobs_buildroots_pkg_uuid ON jobs_buildroots USING btree (pkg_uuid);
---
--- Name: jobs_test; Type: INDEX; Schema: public; Owner: pakfire; Tablespace:
---
-
-CREATE INDEX jobs_test ON jobs USING btree (test) WHERE (deleted_at IS NULL);
-
-
--
-- Name: mirrors_checks_sort; Type: INDEX; Schema: public; Owner: pakfire; Tablespace:
--
package_name = build.pkg.name
# Delete the build and everything that comes with it.
- build.delete()
+ with self.db.transaction():
+ build.delete()
return self.redirect("/package/%s" % package_name)