-
Notifications
You must be signed in to change notification settings - Fork 15
Description
When an Admin creates a Profile Key Metric and uses a dataset that is not for the same geography hierarchy the code breaks.
In the example I found Youth Explorer has the Profile Key Metric Population which uses the dataset Population Demographics and the variable Population.
The Profile YE uses the GeographyHierarchy 2011 SA Boundaries but the dataset uses the GeographyHierarchy SA 2011/2016 mix
So when we try to get the profile key metric for a 2011 geography we cannot find the IndicatorDataItems for this geography because it does not exists.
before the data change we kind off checked if the data exists before trying to access it (756ce9a#diff-1b0927ea32f3ab3d70c8c2053e7db9f5014219fbbf5a13eeccb42167c34561a2L32) but now we don't.
Sentry error:
'NoneType' object has no attribute 'data'
Before:
indicator_data = IndicatorData.objects.filter(indicator__profilekeymetrics=profile_key_metric, geography=geography)
if indicator_data.count() > 0:
subindicator = get_subindicator(profile_key_metric)
data = indicator_data.first().data
After:
data = get_indicator_data(profile_key_metric, [geography]).first().data
Staging area (0.13 cont)
https://trello.com/c/ppvREW9f/758-bug-key-metrics-wrong-geography-for-dataset