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

MetricsSerializer breaks for missing subindicator #203

Open
3 tasks
adieyal opened this issue Jan 27, 2021 · 0 comments
Open
3 tasks

MetricsSerializer breaks for missing subindicator #203

adieyal opened this issue Jan 27, 2021 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@adieyal
Copy link
Contributor

adieyal commented Jan 27, 2021

In MetricsSerializer there is an error when the Subindicator is not available for a specific geography:

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 # TODO what to do with multiple results
return data["subindicators"][subindicator]

If subindicator is not available this will result in a 500 server error. With KeyError

There are several things that need to happen here:

  • create a test for this edge case
  • use .get instead of []
  • return a default value if the subindicator is missing: N/A

https://trello.com/c/svbZLvHv/650-absolute-value-calculator-bug

@milafrerichs milafrerichs added this to the 0.13 milestone Feb 2, 2021
@emre2038 emre2038 assigned emre2038 and unassigned emre2038 Feb 2, 2021
@milafrerichs milafrerichs changed the title Absolute value calculator bug MetricsSerializer breaks for missing sub indicator Feb 25, 2021
@milafrerichs milafrerichs changed the title MetricsSerializer breaks for missing sub indicator MetricsSerializer breaks for missing subindicator Feb 25, 2021
@milafrerichs milafrerichs added the bug Something isn't working label Feb 25, 2021
@milafrerichs milafrerichs linked a pull request Mar 12, 2021 that will close this issue
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants