From 73e8b3e7c00b1b2686ae0df6d406181b6c3808a7 Mon Sep 17 00:00:00 2001 From: Magnus Granberg Date: Mon, 26 Jun 2023 23:49:07 +0200 Subject: Add support to remove ebuilds in db Signed-off-by: Magnus Granberg --- buildbot_gentoo_ci/db/versions.py | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/buildbot_gentoo_ci/db/versions.py b/buildbot_gentoo_ci/db/versions.py index 6b534f3..0aaac1b 100644 --- a/buildbot_gentoo_ci/db/versions.py +++ b/buildbot_gentoo_ci/db/versions.py @@ -131,6 +131,46 @@ class VersionsConnectorComponent(base.DBConnectorComponent): res = yield self.db.pool.do(thd) return res + @defer.inlineCallbacks + def getEbuildsByPackage(self, p_uuid, deleted=False): + def thd(conn): + tbl = self.db.model.versions + q = tbl.select() + q = q.where(tbl.c.deleted == deleted) + q = q.where(tbl.c.package_uuid == p_uuid) + return [self._row2dict(conn, row) + for row in conn.execute(q).fetchall()] + res = yield self.db.pool.do(thd) + return res + + @defer.inlineCallbacks + def removeVersion(self, uuid): + def thd(conn, no_recurse=False): + tbl = self.db.model.versions + q = tbl.delete() + q = q.where(tbl.c.uuid == uuid) + conn.execute(q) + yield self.db.pool.do(thd) + + @defer.inlineCallbacks + def removeVersionMetadata(self, version_uuid): + def thd(conn, no_recurse=False): + tbl = self.db.model.versions_metadata + q = tbl.delete() + q = q.where(tbl.c.version_uuid == version_uuid) + conn.execute(q) + yield self.db.pool.do(thd) + + @defer.inlineCallbacks + def removeVersionKeyword(self, version_uuid): + def thd(conn, no_recurse=False): + tbl = self.db.model.versions_keywords + q = tbl.delete() + q = q.where(tbl.c.version_uuid == version_uuid) + conn.execute(q) + yield self.db.pool.do(thd) + + def _row2dict(self, conn, row): return dict( uuid=row.uuid, -- cgit v1.2.3-65-gdbad