Skip to content

Bug | key metrics | Wrong Geography for Dataset #287

@adieyal

Description

@adieyal

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions