Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
Additional tweaks to get_stat_data, fix recodes
Browse files Browse the repository at this point in the history
  • Loading branch information
longhotsummer committed Feb 4, 2016
1 parent f8838e9 commit b54b0e8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api/models/tables.py
Expand Up @@ -227,17 +227,17 @@ def get_stat_data(self, geo_level, geo_code, fields=None, key_order=None,

# set the recoded field name, noting that the key may already
# exist if another column recoded to it
results.setdefault(key, {'name': recode.get(field, self.columns[field]['name'])})
field_info = results.setdefault(key, {'name': recode.get(field, self.columns[field]['name'])})

if percent:
# sum up existing values, if any
val = val + results.get('numerators', {}).get('this', 0)
results[key]['values'] = {'this': p(val, total)}
results[key]['numerators'] = {'this': val}
val = val + field_info.get('numerators', {}).get('this', 0)
field_info['values'] = {'this': p(val, total)}
field_info['numerators'] = {'this': val}
else:
# sum up existing values, if any
val = val + results.get('values', {}).get('this', 0)
results[key]['values'] = {'this': val}
val = val + field_info.get('values', {}).get('this', 0)
field_info['values'] = {'this': val}

add_metadata(results, self)
return results, total
Expand Down

0 comments on commit b54b0e8

Please sign in to comment.