skalnik / aqi-wtf

😷 WTF is the AQI near me right now?!
https://aqi.wtf
MIT License
44 stars 12 forks source link

change behavior if pm < 0 so app still displays a number and a status #75

Closed danisyellis closed 2 years ago

danisyellis commented 2 years ago

Today and last week I've been seeing results like the one mentioned here https://github.com/skalnik/aqi-wtf/pull/60#issuecomment-706265098
I've attached two images of my own - one from Chrome on a laptop and one from an iPhone.

I've tracked it down to the fact that it's possible to get a pm that's less than 0 (for example, if the AQI is less than .53 and the humidity is very high, which has been true in parts of SF today.) In that case, the code was returning, and displaying, the pm number (without rounding, because the rounding only happens if calqAQI is called), and then on line 113 getAQIClass returned undefined because AQI was less than 0, so we didn't get the awesome happy face and green background.

I can't think of any reason why the negative pm should be returned instead of the number a user would understand - 0 - but let me know if I've missed something important! NOTE: I tested my change locally (on line 261 I called aqiFromPM with -.5) and it worked.

And while I'm here, thanks so much for AQI.wtf! I use it all the time and the smiley face when the AQI is good makes me smile. Also, this codebase was so easy to read! Much easier to follow than most code I've looked at. Thanks again.

AQIWTFscreenshot

IMG_5457

vercel[bot] commented 2 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/skalnik/aqi-wtf/DTzj8DcQX6a8MkUYR4fk4gt3RP4x
✅ Preview: https://aqi-wtf-git-fork-danisyellis-fixpm0-skalnik.vercel.app