Skip to content

Commit

Permalink
Trac #2660 [nine] buildrequests data API uses popBooleanFilter for no…
Browse files Browse the repository at this point in the history
…n-booleans

 - This commit implements the 3 dustin's comments:
   - process buildsetid with the eq operator in the DB API
   - implement popStringFilter (only pops an eq filter)
   - add type annotation in master/docs/developer/database.rst
  • Loading branch information
delanne committed Jan 22, 2014
1 parent bf64b6a commit 36bd304
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
4 changes: 4 additions & 0 deletions master/buildbot/data/buildrequests.py
Expand Up @@ -104,12 +104,16 @@ def get(self, resultSpec, kwargs):
else:
claimed = resultSpec.popBooleanFilter('claimed')

bsid = resultSpec.popFilter('buildsetid', 'eq')
if bsid:
bsid = bsid[0]
branch = resultSpec.popStringFilter('branch')
repository = resultSpec.popStringFilter('repository')
buildrequests = yield self.master.db.buildrequests.getBuildRequests(
buildername=buildername,
complete=complete,
claimed=claimed,
bsid=bsid,
branch=branch,
repository=repository)
if buildrequests:
Expand Down
5 changes: 4 additions & 1 deletion master/buildbot/data/resultspec.py
Expand Up @@ -77,7 +77,10 @@ def popBooleanFilter(self, field):
if neVals and len(neVals) == 1:
return not neVals[0]

popStringFilter = popBooleanFilter
def popStringFilter(self, field):
eqVals = self.popFilter(field, 'eq')
if eqVals and len(eqVals) == 1:
return eqVals[0]

def removePagination(self):
self.limit = self.offset = None
Expand Down
3 changes: 3 additions & 0 deletions master/buildbot/test/unit/test_data_buildrequests.py
Expand Up @@ -155,6 +155,7 @@ def testGetNoFilters(self):
yield self.callGet(('buildrequest',))
getBuildRequestsMock.assert_called_with(
buildername=None,
bsid=None,
complete=None,
claimed=None,
branch=None,
Expand All @@ -174,6 +175,7 @@ def testGetFilters(self):
resultSpec=resultspec.ResultSpec(filters=[f1, f2, f3, f4, f5]))
getBuildRequestsMock.assert_called_with(
buildername=None,
bsid=55,
complete=False,
claimed=True,
branch='mybranch',
Expand All @@ -191,6 +193,7 @@ def testGetClaimedByMasterIdFilters(self):
resultSpec=resultspec.ResultSpec(filters=[f1, f2]))
getBuildRequestsMock.assert_called_with(
buildername=None,
bsid=None,
complete=None,
claimed=fakedb.FakeBuildRequestsComponent.MASTER_ID,
branch=None,
Expand Down
12 changes: 6 additions & 6 deletions master/docs/developer/database.rst
Expand Up @@ -100,11 +100,11 @@ buildrequests
* ``complete`` (boolean, true if the request is complete)
* ``complete_at`` (datetime object, time this request was completed)
* ``submitted_at`` (datetime object, time this request was completed)
* ``results``
* ``branch``
* ``repository``
* ``codebase``
* ``waited_for``
* ``results`` (integer result code)
* ``branch`` (string, the branch associated with the request)
* ``repository`` (string, the repository associated with the request)
* ``codebase`` (string, the codebase associated with the request)
* ``waited_for`` (boolean)

.. py:method:: getBuildRequest(brid)
Expand Down Expand Up @@ -600,7 +600,7 @@ buildsets
complete=None):
:param count: maximum number of buildsets to retrieve (required).
:type branch: integer
:type count: integer
:param branch: optional branch name. If specified, only buildsets
affecting such branch will be returned.
:type branch: string
Expand Down

0 comments on commit 36bd304

Please sign in to comment.