Skip to content

Commit

Permalink
Merge pull request buildbot#8149 from p12tic/db-simplify-get-build-re…
Browse files Browse the repository at this point in the history
…quest

db: Simplify BuildRequestsConnectorComponent.getBuildRequest()
  • Loading branch information
p12tic authored Oct 21, 2024
2 parents 9e81e6e + 2890929 commit ce57b88
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion master/buildbot/db/buildrequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,20 @@ class BrDict(BuildRequestModel):


class BuildRequestsConnectorComponent(base.DBConnectorComponent):
def _simple_sa_select_query(self):
reqs_tbl = self.db.model.buildrequests
claims_tbl = self.db.model.buildrequest_claims
builder_tbl = self.db.model.builders

from_clause = reqs_tbl.outerjoin(claims_tbl, reqs_tbl.c.id == claims_tbl.c.brid)
from_clause = from_clause.join(builder_tbl, reqs_tbl.c.builderid == builder_tbl.c.id)

return sa.select(
reqs_tbl,
claims_tbl,
builder_tbl.c.name.label('buildername'),
).select_from(from_clause)

def _saSelectQuery(self):
reqs_tbl = self.db.model.buildrequests
claims_tbl = self.db.model.buildrequest_claims
Expand All @@ -114,7 +128,7 @@ def _saSelectQuery(self):
def getBuildRequest(self, brid) -> defer.Deferred[BuildRequestModel | None]:
def thd(conn) -> BuildRequestModel | None:
reqs_tbl = self.db.model.buildrequests
q = self._saSelectQuery()
q = self._simple_sa_select_query()
q = q.where(reqs_tbl.c.id == brid)
res = conn.execute(q)
row = res.fetchone()
Expand Down

0 comments on commit ce57b88

Please sign in to comment.