Skip to content

Commit

Permalink
package_list performance fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi authored and tobes committed Jun 27, 2013
1 parent 952f199 commit a4f0cf6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions ckan/logic/action/get.py
Expand Up @@ -69,16 +69,16 @@ def package_list(context, data_dict):
'''
model = context["model"]
api = context.get("api_version", 1)
ref_package_by = 'id' if api == 2 else 'name'

_check_access('package_list', context, data_dict)

query = model.Session.query(model.PackageRevision)
query = query.filter(model.PackageRevision.state=='active')
query = query.filter(model.PackageRevision.current==True)

packages = query.all()
return [getattr(p, ref_package_by) for p in packages]
from ckan.model.package import package_revision_table
col = (package_revision_table.c.id
if api == 2 else package_revision_table.c.name)
query = _select([col])
query = query.where(_and_(package_revision_table.c.state=='active',
package_revision_table.c.current==True))
return zip(*query.execute())

def current_package_list_with_resources(context, data_dict):
'''Return a list of the site's datasets (packages) and their resources.
Expand Down

0 comments on commit a4f0cf6

Please sign in to comment.