Skip to content
Permalink
Browse files

Merge pull request #557 from fedora-infra/feature/unscalable-json

Short-circuit recursion specifically for test cases.
  • Loading branch information...
lmacken committed Sep 10, 2015
2 parents cdc9a2e + 01367c5 commit 5d42c36aef9dc5e3829e0d589c937597880d686b
Showing with 13 additions and 4 deletions.
  1. +13 −4 bodhi/models/models.py
@@ -1806,18 +1806,27 @@ def requested_tag(self):
'Unable to determine requested tag for %s.' % self.title)
return tag

def __json__(self, *args, **kwargs):
result = super(Update, self).__json__(*args, **kwargs)
def __json__(self, request=None, anonymize=False):
result = super(Update, self).__json__(
request=request, anonymize=anonymize)
# Duplicate alias as updateid for backwards compat with bodhi1
result['updateid'] = result['alias']
# Also, put the update submitter's name in the same place we put
# it for bodhi1 to make fedmsg.meta compat much more simple.
result['submitter'] = result['user']['name']

# For https://github.com/fedora-infra/bodhi/issues/270, throw the JSON
# of the test cases in our output as well.
# of the test cases in our output as well but take extra care to
# short-circuit some of the insane recursion for
# https://github.com/fedora-infra/bodhi/issues/343
seen = [Package, TestCaseKarma]
result['test_cases'] = [
test.__json__(*args, **kwargs) for test in self.full_test_cases
test._to_json(
obj=test,
seen=seen,
request=request,
anonymize=anonymize)
for test in self.full_test_cases
]

return result

0 comments on commit 5d42c36

Please sign in to comment.
You can’t perform that action at this time.