Merge pull request #293 from Reena-cell/develop

bugfix/ API Version in metric
This commit is contained in:
Simon Redfern 2023-03-02 13:40:17 +01:00 committed by GitHub
commit 8b0d96069e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -40,7 +40,7 @@ def get_api_versions(request):
urlpath = '/api/versions'
result = api.get(urlpath)
if 'scanned_api_versions' in result:
return [apiversion['apiShortVersion'] for apiversion in sorted(result['scanned_api_versions'], key=lambda d: d['apiShortVersion'])]
return [apiversion['API_VERSION'] for apiversion in sorted(result['scanned_api_versions'], key=lambda d: d['API_VERSION'])]
else:
return []
except APIError as err:

View File

@ -192,7 +192,7 @@ class APIMetricsView(MetricsView):
fields = form.fields
try:
fields['consumer_id'].choices = self.api.get_consumer_id_choices()
#fields['apiShortVersion'].choices = self.api.get_api_version_choices()
fields['implemented_in_version'].choices = self.api.get_api_version_choices()
except APIError as err:
messages.error(self.request, err)
except Exception as err:
@ -202,8 +202,8 @@ class APIMetricsView(MetricsView):
def get_context_data(self, **kwargs):
context = super(APIMetricsView, self).get_context_data(**kwargs)
context.update({
'consumer_id': get_consumers(self.request)
#'API_VERSION': get_api_versions(self.request)
'consumer_id': get_consumers(self.request),
'API_VERSION': get_api_versions(self.request)
})
return context

View File

@ -172,8 +172,8 @@ class API(object):
"""Gets a list of APIs Version and APIs Version as used by form choices"""
choices = [('', _('Choose ...'))]
result = self.get('/api/versions')
for apiversion in sorted(result['scanned_api_versions'], key=lambda d: d['apiShortVersion']) :
choices.append((apiversion['apiShortVersion'], apiversion['apiShortVersion']))
for version in sorted(result['scanned_api_versions'], key=lambda d: d['API_VERSION']) :
choices.append((version['API_VERSION'], version['API_VERSION']))
return choices