Skip to content

Commit

Permalink
update table count to check for bad json feed
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Lind committed Oct 3, 2016
1 parent f8695ca commit 13bcdd4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions indicators/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,12 +838,16 @@ def getTableCount(url,table_id):

# loop over the result table and count the number of records for actuals
actual_data = get_table(filter_url)

print actual_data

count = 0

if actual_data:
for item in actual_data['data']:
# check if json data is in the 'data' attribute or at the top level of the JSON object
try:
looper = actual_data['data']
except KeyError:
looper = actual_data

for item in looper:
count = count + 1

# update with new count
Expand Down Expand Up @@ -899,7 +903,7 @@ def collecteddata_import(request):
remote_owner = item['owner']['username']

#send table ID to count items in data
count = getTableCount(filter_url,id)
count = getTableCount(url,id)

# get the users country
countries = getCountry(request.user)
Expand Down

0 comments on commit 13bcdd4

Please sign in to comment.