Skip to content

Commit

Permalink
[2403] home page speed improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
kindly committed May 18, 2012
1 parent 5589f0f commit 5cc6143
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ckan/controllers/home.py
Expand Up @@ -49,8 +49,11 @@ def index(self):
c.package_count = query['count']
c.facets = query['facets']

# group search
data_dict = {'order_by': 'packages', 'all_fields': 1}
#only give the terms to group dictize that are returned in the facets
#as full results take a lot longer
if 'groups' in c.facets:
data_dict['groups'] = c.facets['groups'].keys()
c.groups = ckan.logic.get_action('group_list')(context, data_dict)
except SearchError, se:
c.package_count = 0
Expand Down
3 changes: 3 additions & 0 deletions ckan/logic/action/get.py
Expand Up @@ -221,6 +221,7 @@ def group_list(context, data_dict):
model = context['model']
user = context['user']
api = context.get('api_version')
groups = data_dict.get('groups')
ref_group_by = 'id' if api == 2 else 'name';
order_by = data_dict.get('order_by', 'name')
if order_by not in set(('name', 'packages')):
Expand All @@ -232,6 +233,8 @@ def group_list(context, data_dict):
query = model.Session.query(model.Group).join(model.GroupRevision)
query = query.filter(model.GroupRevision.state=='active')
query = query.filter(model.GroupRevision.current==True)
if groups:
query = query.filter(model.GroupRevision.name.in_(groups))

if order_by == 'name':
sort_by, reverse = 'name', False
Expand Down

0 comments on commit 5cc6143

Please sign in to comment.