Skip to content

Commit

Permalink
Removed items that had no id in JSON
Browse files Browse the repository at this point in the history
removed 4 country limit on ExploreData
  • Loading branch information
Bluestreak2k5 committed Dec 5, 2011
1 parent fa82b29 commit 0ecbbce
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion hunchworks/templates/explore/explore.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ <h1>Explore Data</h1>
});
$("#id_country").tokenInput( {{ countries|safe }}, {
prePopulate: {{ countries_prepop|safe }},
tokenLimit: 4,
minChars: 2
});
});
Expand Down
9 changes: 6 additions & 3 deletions hunchworks/utils/data/worldbank.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ def _value(value):

def chart(data):
all_country_data = {}
country = ""
country = None

for item in reversed(data):

if country != item["country"]["value"]:
country = item["country"]["value"]
all_country_data[country] = {}
if item["country"].get("id", "") != "":
print item["country"].get("id", "")
country = item["country"]["value"]
all_country_data[country] = {}

all_country_data[country][item["date"]] = _value(item["value"])

Expand All @@ -58,6 +60,7 @@ def chart(data):

# country_keys are the unique country names for all countries in the data.
country_keys = all_country_data.keys()
print country_keys

# final_country_data will be an array of arrays looking like this:
# [ ["1998", 13000, 14000], ["1999", 15000, 16000], ["2000", 17000, 20000] ]
Expand Down
9 changes: 5 additions & 4 deletions hunchworks/views/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ def _format_for_tokeninput(key):

for item in data:
thing = item[key].copy()
thing["name"] = thing["value"]
del thing["value"]
if thing.get("id", "") != "":
thing["name"] = thing["value"]
del thing["value"]

if not thing in things:
things.append(thing)
if not thing in things:
things.append(thing)

return things

Expand Down

0 comments on commit 0ecbbce

Please sign in to comment.