diff options
Diffstat (limited to 'buildbot_gentoo_ci/db/builds.py')
-rw-r--r-- | buildbot_gentoo_ci/db/builds.py | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/buildbot_gentoo_ci/db/builds.py b/buildbot_gentoo_ci/db/builds.py index 1cf2439..21adcc0 100644 --- a/buildbot_gentoo_ci/db/builds.py +++ b/buildbot_gentoo_ci/db/builds.py @@ -15,7 +15,7 @@ # Copyright Buildbot Team Members # Origins: buildbot.db.* # Modifyed by Gentoo Authors. -# Copyright 2021 Gentoo Authors +# Copyright 2023 Gentoo Authors import uuid import sqlalchemy as sa @@ -44,7 +44,9 @@ class BuildsConnectorComponent(base.DBConnectorComponent): requested=project_build_data['requested'], created_at=created_at, buildbot_build_id=0, - build_id=new_number)) + build_id=new_number, + bug_id=0 + )) except (sa.exc.IntegrityError, sa.exc.ProgrammingError): id = None new_number = None @@ -57,7 +59,6 @@ class BuildsConnectorComponent(base.DBConnectorComponent): def setStatusBuilds(self, id, status): updated_at = int(self.master.reactor.seconds()) def thd(conn, no_recurse=False): - tbl = self.db.model.projects_builds q = tbl.update() q = q.where(tbl.c.id == id) @@ -69,10 +70,57 @@ class BuildsConnectorComponent(base.DBConnectorComponent): def setBuildbotBuildIdBuilds(self, id, buildbot_build_id): updated_at = int(self.master.reactor.seconds()) def thd(conn, no_recurse=False): - tbl = self.db.model.projects_builds q = tbl.update() q = q.where(tbl.c.id == id) conn.execute(q, updated_at=updated_at, buildbot_build_id=buildbot_build_id) yield self.db.pool.do(thd) + + @defer.inlineCallbacks + def setBugIdBuilds(self, id, bug_id): + updated_at = int(self.master.reactor.seconds()) + def thd(conn, no_recurse=False): + tbl = self.db.model.projects_builds + q = tbl.update() + q = q.where(tbl.c.id == id) + conn.execute(q, updated_at=updated_at, bug_id=bug_id) + yield self.db.pool.do(thd) + + @defer.inlineCallbacks + def getBuildsByVersionUuid(self, uuid): + def thd(conn): + tbl = self.db.model.projects_builds + q = tbl.select() + q = q.where(tbl.c.version_uuid == uuid) + res = conn.execute(q) + row = res.fetchone() + return [self._row2dict(conn, row) + for row in conn.execute(q).fetchall()] + res = yield self.db.pool.do(thd) + return res + + @defer.inlineCallbacks + def removeBuild(self, id): + def thd(conn, no_recurse=False): + tbl = self.db.model.projects_builds + q = tbl.delete() + q = q.where(tbl.c.id == id) + conn.execute(q) + yield self.db.pool.do(thd) + + def _row2dict(self, conn, row): + return dict( + id=row.id, + build_id=row.build_id, + project_uuid=row.project_uuid, + version_uuid=row.version_uuid, + buildbot_build_id=row.buildbot_build_id, + bug_id=row.bug_id, + status=row.status, + requested=row.requested, + created_at=row.created_at, + updated_at=row.updated_at, + deleted=row.deleted, + deleted_at=row.deleted_at + ) |