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

Handle "other" modes without mappings in the JSON #807

Merged
merged 1 commit into from
Jan 20, 2022

Conversation

shankari
Copy link
Contributor

The custom footprint creation currently assumes that all modes have an CO2 entry in the JSON.
This is true, except in the case where the user selects "other" and puts in a custom mode.
In that case, we have no mapping, so the footprint map has an entry for {mode: undefined}
which causes the footprint calculations to return NaN.

We instead check whether we have a mapping and return undefined in that case.
We also filter out the undefined entries.

After this change, the custom other modes will be excluded, and we will use the
standard 0 - max footprint range to handle them.

The calorie/MET calculation already worked like this; so this just ensures that
both sets of values are consistent.

This fixes e-mission/e-mission-docs#697

The custom footprint creation currently assumes that all modes have an CO2 entry in the JSON.
This is true, except in the case where the user selects "other" and puts in a custom mode.
In that case, we have no mapping, so the footprint map has an entry for {mode: undefined}
which causes the footprint calculations to return NaN.

We instead check whether we have a mapping and return `undefined` in that case.
We also filter out the undefined entries.

After this change, the custom other modes will be excluded, and we will use the
standard 0 - max footprint range to handle them.

The calorie/MET calculation already worked like this; so this just ensures that
both sets of values are consistent.

This fixes e-mission/e-mission-docs#697
@shankari
Copy link
Contributor Author

Screenshot

Unknown mode Still works
Screenshot_1642664336 Screenshot_1642664339

@shankari shankari merged commit f12c54b into e-mission:master Jan 20, 2022
shankari added a commit that referenced this pull request Jan 20, 2022
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

Successfully merging this pull request may close these issues.

Footprint range not displayed on iOS for certain users
1 participant