Skip to content

Commit

Permalink
map code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
joetsoi committed Mar 29, 2013
1 parent d7beee0 commit 8d51140
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions ckanext/pdeu/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,19 @@ def data(self):
o = json.load(f)

# Get the package count by country
q = Session.query(distinct(PackageExtra.value),
func.count(PackageExtra.value)).filter(
PackageExtra.key == u'eu_country').group_by(
PackageExtra.value)
values = {}
for country, count in q.all():
values[country] = count

q = Session.query(
distinct(PackageExtra.value),
func.count(PackageExtra.value)
).\
filter(PackageExtra.key == u'eu_country').\
group_by(PackageExtra.value)

values = dict(q.all())
# Set the package count for each country

for ft in o['features']:
code = ft['properties']['NUTS']
ft['properties']['packages'] = (
values[code] if code in values else 0)
ft['properties']['packages'] = (values.get(code, 0))

response.content_type = 'application/json'
response.pragma = None
Expand Down

0 comments on commit 8d51140

Please sign in to comment.