Skip to content
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

Bug | key metrics | Wrong Geography for Dataset #287

Open
adieyal opened this issue Jun 2, 2021 · 0 comments
Open

Bug | key metrics | Wrong Geography for Dataset #287

adieyal opened this issue Jun 2, 2021 · 0 comments

Comments

@adieyal
Copy link
Contributor

adieyal commented Jun 2, 2021

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.

https://production.wazimap-ng.openup.org.za/admin/profile/profilekeymetrics/61/change/?_changelist_filters=profile__name%3DYouth%2BExplorer

https://production.wazimap-ng.openup.org.za/admin/datasets/dataset/123/change/?_changelist_filters=q%3DPopulation

Sentry error:

https://sentry.io/organizations/openupsa/issues/2327735278/?project=5257787&query=is%3Aunresolved&statsPeriod=90d

'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

https://github.com/OpenUpSA/wazimap-ng/blob/master/wazimap_ng/profile/serializers/metrics_serializer.py#L18-L20

Staging area (0.13 cont)

https://trello.com/c/ppvREW9f/758-bug-key-metrics-wrong-geography-for-dataset

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant