summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Cacqueray <tdecacqu@redhat.com>2019-02-13 00:20:42 +0000
committerTristan Cacqueray <tdecacqu@redhat.com>2019-02-13 00:20:42 +0000
commit5c342421f1af96766ea8a734d5fbccb701936e75 (patch)
tree97630d87d199656a920db2fc74b7f5d78137888c
parentd540ebfe3220064e6d01c7059f98bf5984231422 (diff)
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
Notes
Notes (review): Code-Review+2: Clint 'SpamapS' Byrum <clint@fewbar.com> Code-Review+2: James E. Blair <corvus@inaugust.com> Workflow+1: James E. Blair <corvus@inaugust.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Thu, 14 Feb 2019 00:09:11 +0000 Reviewed-on: https://review.openstack.org/636504 Project: openstack-infra/zuul Branch: refs/heads/master
-rwxr-xr-xtests/unit/test_web.py1
-rw-r--r--zuul/driver/sql/sqlconnection.py6
-rwxr-xr-xzuul/web/__init__.py7
3 files changed, 3 insertions, 11 deletions
diff --git a/tests/unit/test_web.py b/tests/unit/test_web.py
index 60c6707..f1c9da1 100755
--- a/tests/unit/test_web.py
+++ b/tests/unit/test_web.py
@@ -725,7 +725,6 @@ class TestBuildInfo(ZuulDBTestCase, BaseTestWeb):
725 725
726 buildsets = self.get_url("api/tenant/tenant-one/buildsets").json() 726 buildsets = self.get_url("api/tenant/tenant-one/buildsets").json()
727 self.assertEqual(2, len(buildsets)) 727 self.assertEqual(2, len(buildsets))
728 self.assertEqual(3, len(buildsets[0]["builds"]))
729 728
730 729
731class TestArtifacts(ZuulDBTestCase, BaseTestWeb, AnsibleZuulTestCase): 730class TestArtifacts(ZuulDBTestCase, BaseTestWeb, AnsibleZuulTestCase):
diff --git a/zuul/driver/sql/sqlconnection.py b/zuul/driver/sql/sqlconnection.py
index f657575..9367c72 100644
--- a/zuul/driver/sql/sqlconnection.py
+++ b/zuul/driver/sql/sqlconnection.py
@@ -107,15 +107,12 @@ class DatabaseSession(object):
107 107
108 def getBuildsets(self, tenant=None, project=None, pipeline=None, 108 def getBuildsets(self, tenant=None, project=None, pipeline=None,
109 change=None, branch=None, patchset=None, ref=None, 109 change=None, branch=None, patchset=None, ref=None,
110 newrev=None, uuid=None, job_name=None, result=None, 110 newrev=None, uuid=None, result=None,
111 limit=50, offset=0): 111 limit=50, offset=0):
112 112
113 build_table = self.connection.zuul_build_table
114 buildset_table = self.connection.zuul_buildset_table 113 buildset_table = self.connection.zuul_buildset_table
115 114
116 q = self.session().query(self.connection.buildSetModel).\ 115 q = self.session().query(self.connection.buildSetModel).\
117 join(self.connection.buildModel).\
118 options(orm.contains_eager(self.connection.buildSetModel.builds)).\
119 with_hint(buildset_table, 'USE INDEX (PRIMARY)', 'mysql') 116 with_hint(buildset_table, 'USE INDEX (PRIMARY)', 'mysql')
120 117
121 q = self.listFilter(q, buildset_table.c.tenant, tenant) 118 q = self.listFilter(q, buildset_table.c.tenant, tenant)
@@ -128,7 +125,6 @@ class DatabaseSession(object):
128 q = self.listFilter(q, buildset_table.c.newrev, newrev) 125 q = self.listFilter(q, buildset_table.c.newrev, newrev)
129 q = self.listFilter(q, buildset_table.c.uuid, uuid) 126 q = self.listFilter(q, buildset_table.c.uuid, uuid)
130 q = self.listFilter(q, buildset_table.c.result, result) 127 q = self.listFilter(q, buildset_table.c.result, result)
131 q = self.listFilter(q, build_table.c.job_name, job_name)
132 128
133 q = q.order_by(buildset_table.c.id.desc()).\ 129 q = q.order_by(buildset_table.c.id.desc()).\
134 limit(limit).\ 130 limit(limit).\
diff --git a/zuul/web/__init__.py b/zuul/web/__init__.py
index 6670826..ac4a80e 100755
--- a/zuul/web/__init__.py
+++ b/zuul/web/__init__.py
@@ -515,10 +515,7 @@ class ZuulWebAPI(object):
515 'ref': buildset.ref, 515 'ref': buildset.ref,
516 'newrev': buildset.newrev, 516 'newrev': buildset.newrev,
517 'ref_url': buildset.ref_url, 517 'ref_url': buildset.ref_url,
518 'builds': []
519 } 518 }
520 for build in buildset.builds:
521 ret["builds"].append(self.buildToDict(build))
522 return ret 519 return ret
523 520
524 @cherrypy.expose 521 @cherrypy.expose
@@ -526,13 +523,13 @@ class ZuulWebAPI(object):
526 @cherrypy.tools.json_out(content_type='application/json; charset=utf-8') 523 @cherrypy.tools.json_out(content_type='application/json; charset=utf-8')
527 def buildsets(self, tenant, project=None, pipeline=None, change=None, 524 def buildsets(self, tenant, project=None, pipeline=None, change=None,
528 branch=None, patchset=None, ref=None, newrev=None, 525 branch=None, patchset=None, ref=None, newrev=None,
529 uuid=None, job_name=None, result=None, limit=50, skip=0): 526 uuid=None, result=None, limit=50, skip=0):
530 connection = self._get_connection(tenant) 527 connection = self._get_connection(tenant)
531 528
532 buildsets = connection.getBuildsets( 529 buildsets = connection.getBuildsets(
533 tenant=tenant, project=project, pipeline=pipeline, change=change, 530 tenant=tenant, project=project, pipeline=pipeline, change=change,
534 branch=branch, patchset=patchset, ref=ref, newrev=newrev, 531 branch=branch, patchset=patchset, ref=ref, newrev=newrev,
535 uuid=uuid, job_name=job_name, result=result, 532 uuid=uuid, result=result,
536 limit=limit, offset=skip) 533 limit=limit, offset=skip)
537 534
538 resp = cherrypy.response 535 resp = cherrypy.response