Merge "Refactor to a single request for latest apps"
This commit is contained in:
commit
5484afea91
@ -183,25 +183,12 @@ def cleaned_latest_apps(request):
|
|||||||
Verifies, that apps in the list are either public or belong to current
|
Verifies, that apps in the list are either public or belong to current
|
||||||
project.
|
project.
|
||||||
"""
|
"""
|
||||||
|
id_param = "in:" + ",".join(request.session.get('latest_apps', []))
|
||||||
cleaned_apps, cleaned_app_ids = [], []
|
query_params = {'type': 'Application', 'catalog': True, 'id': id_param}
|
||||||
for app_id in request.session.get('latest_apps', []):
|
user_apps = list(api.muranoclient(request).packages.filter(**query_params))
|
||||||
try:
|
request.session['latest_apps'] = collections.deque([app.id
|
||||||
# TODO(kzaitsev): we have to update this to 1 request per list of
|
for app in user_apps])
|
||||||
# apps. Should be trivial and should remove the need to verify that
|
return user_apps
|
||||||
# apps are available. bug/1559066
|
|
||||||
app = api.muranoclient(request).packages.get(app_id)
|
|
||||||
except exc.HTTPNotFound:
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
if app.type != 'Application':
|
|
||||||
continue
|
|
||||||
if (app.owner_id == request.session['token'].project['id'] or
|
|
||||||
app.is_public):
|
|
||||||
cleaned_apps.append(app)
|
|
||||||
cleaned_app_ids.append(app_id)
|
|
||||||
request.session['latest_apps'] = collections.deque(cleaned_app_ids)
|
|
||||||
return cleaned_apps
|
|
||||||
|
|
||||||
|
|
||||||
def clear_forms_data(func):
|
def clear_forms_data(func):
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
features:
|
||||||
|
- Improved the performance of 'Recent Activity' panel at the
|
||||||
|
'Browse Catalog' page.
|
||||||
|
It was done with refactoring single request for every latest app
|
||||||
|
with single for all, using new API 'in' operator.
|
Loading…
Reference in New Issue
Block a user