-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add national risk data and tests #69
Conversation
Pull Request Test Coverage Report for Build 7572306362
💛 - Coveralls |
if hxl_tag == "#risk+class": | ||
value = _get_risk_class_code_from_data(value) | ||
dict_of_dicts_add(rows, admin_code, hxl_tag, value) | ||
for location in rows: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the purpose of this additional loop (rather than placing the code in this loop where the dict_of_dicts_add
line is) to try to ensure that rows are grouped by location rather than by #risk+x when you look at them in the db table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format of the national risk table is wide rather than long, unlike the other tables (example), so I'm essentially transposing the results dictionary so it's location based instead of hxl tag based. The only other way I could think of to do that was using map to pull out the values of each dictionary for each location, but it was more difficult to understand when I read it back:
hxl_tags = admin_results["headers"][1]
locations = list(admin_results["values"][0].keys())
for location in locations:
values = list(map(lambda x: x[location], admin_results["values"]))
values = {hxl_tag: value for hxl_tag in hxl_tags for value in values}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've approved. I made a comment about the additional loop for you to look at.
I looked at it again and found a way to simplify and avoid the second loop! I'll go ahead and merge. |
This was the easiest way I could think of to construct the rows for the database but happy to implement any suggestions you have!