Browse Source

web: remove build and job_name filter from the buildset route

This change fixes the buildset route limit which incorrectly match
the number of build instead of the number of buildset.

Change-Id: Ia5775a32e646a7107a6dd04328ac36ec681b3b50
changes/04/636504/1
Tristan Cacqueray 2 years ago
parent
commit
5c342421f1
3 changed files with 3 additions and 11 deletions
  1. +0
    -1
      tests/unit/test_web.py
  2. +1
    -5
      zuul/driver/sql/sqlconnection.py
  3. +2
    -5
      zuul/web/__init__.py

+ 0
- 1
tests/unit/test_web.py View File

@ -725,7 +725,6 @@ class TestBuildInfo(ZuulDBTestCase, BaseTestWeb):
buildsets = self.get_url("api/tenant/tenant-one/buildsets").json()
self.assertEqual(2, len(buildsets))
self.assertEqual(3, len(buildsets[0]["builds"]))
class TestArtifacts(ZuulDBTestCase, BaseTestWeb, AnsibleZuulTestCase):


+ 1
- 5
zuul/driver/sql/sqlconnection.py View File

@ -107,15 +107,12 @@ class DatabaseSession(object):
def getBuildsets(self, tenant=None, project=None, pipeline=None,
change=None, branch=None, patchset=None, ref=None,
newrev=None, uuid=None, job_name=None, result=None,
newrev=None, uuid=None, result=None,
limit=50, offset=0):
build_table = self.connection.zuul_build_table
buildset_table = self.connection.zuul_buildset_table
q = self.session().query(self.connection.buildSetModel).\
join(self.connection.buildModel).\
options(orm.contains_eager(self.connection.buildSetModel.builds)).\
with_hint(buildset_table, 'USE INDEX (PRIMARY)', 'mysql')
q = self.listFilter(q, buildset_table.c.tenant, tenant)
@ -128,7 +125,6 @@ class DatabaseSession(object):
q = self.listFilter(q, buildset_table.c.newrev, newrev)
q = self.listFilter(q, buildset_table.c.uuid, uuid)
q = self.listFilter(q, buildset_table.c.result, result)
q = self.listFilter(q, build_table.c.job_name, job_name)
q = q.order_by(buildset_table.c.id.desc()).\
limit(limit).\


+ 2
- 5
zuul/web/__init__.py View File

@ -515,10 +515,7 @@ class ZuulWebAPI(object):
'ref': buildset.ref,
'newrev': buildset.newrev,
'ref_url': buildset.ref_url,
'builds': []
}
for build in buildset.builds:
ret["builds"].append(self.buildToDict(build))
return ret
@cherrypy.expose
@ -526,13 +523,13 @@ class ZuulWebAPI(object):
@cherrypy.tools.json_out(content_type='application/json; charset=utf-8')
def buildsets(self, tenant, project=None, pipeline=None, change=None,
branch=None, patchset=None, ref=None, newrev=None,
uuid=None, job_name=None, result=None, limit=50, skip=0):
uuid=None, result=None, limit=50, skip=0):
connection = self._get_connection(tenant)
buildsets = connection.getBuildsets(
tenant=tenant, project=project, pipeline=pipeline, change=change,
branch=branch, patchset=patchset, ref=ref, newrev=newrev,
uuid=uuid, job_name=job_name, result=result,
uuid=uuid, result=result,
limit=limit, offset=skip)
resp = cherrypy.response


Loading…
Cancel
Save