Ambi dashboard view is missing a truthy case for displaying air_purity #7
Labels
bug
Something isn't working
frontend
Any change related to the Ambi frontend
good first issue
Good for newcomers
If a client adds
air_purity
data that isn't in the literal form of "Dangerous Pollution" or something like that with the first letters uppercase and the others lowercase, it will fail to display and raises a runtime error where it's missing a truthy value for acond
statement.E.g.
This should have a "else" clause that always handles the invalid case but can also handle any kind of upper/lower case scenario as discussed in this Elixir forum post.
Advanced fix to consider:
A better fix would be to make the
air_purity
levels be an enumerated type across the board, from the HW sensor (Edge), ambi_mock_client and to the Ambi web backend. So instead of using strings like "Dangerous Pollution" it would be a type AirPurity with type values:NoPollution
LowPollution
MediumPollution
HighPollution
etc...
The text was updated successfully, but these errors were encountered: