rubyforgood / Flaredown

Flaredown web app and API
http://www.flaredown.com
GNU General Public License v3.0
39 stars 15 forks source link

Update weather API to Tomorrowio #689

Closed cwille97 closed 9 months ago

cwille97 commented 12 months ago

Resolves https://github.com/rubyforgood/Flaredown/issues/535

Context

The Dark Sky API has been completely shut down for some time now so we are migrating to Tomorrow.io to bring back weather data for users.

Approach

I first wrote a small wrapper for the API in Ruby and created a gem for that. This PR removes the old Dark Sky gem and adds my new gem and refactors the weather retriever service to use the new API. By and large the data is mostly backwards compatible with a few exceptions noted below. Notably, it was not necessary to change the Geolocation API since that is still in use. There were some previous reports of getting the wrong weather data for a given location, so it's possible we may still want to replace the Geolocation API (possibly with the browser geolocation API if that continues to be a problem.

Exceptions to backwards compatibility

Tests

Tests to follow, I need to familiarize myself with the VCR package being used here as well as generate the requisite API data for that. Just want to put up an initial draft PR to get some feedback on this so far.

Other resources

Dark Sky (Forecast API wrapper) Tomorrow.io Notes
Humidity humidityAvg
Icon weatherCode Translating Tomorrow weather codes into the most applicable existing icon
precipIntensity rainIntensityAvg, sleetIntensityAvg, snowIntensityAvg DarkSky had 1 value for this and my best guess was to sum these 3
pressure pressureSurfaceLevelAvg DarkSky uses sea level, Tomorrow uses surface level pressure
summary N/A I attempted to recreate this value by including information from the weatherCode and the temperature
temperatureMin temperatureMin DarkSky defaulted to Kelvin
temperatureMax temperatureMax DarkSky defaulted to Kelvin

compwron commented 10 months ago

I am excited for this to go thru!