This project will show the weather for BigCommerce office locations and will automatically pull new data every hour. The frontend client will automatically check for new data every 30 minutes.
The list of requirements to install are:
- Ruby >= 2.6.x
- Postgresql
- Redis
Note: Ruby 2.6.8
is required for Heroku (Support Runtimes).
- Install Postgresql
- Install Redis
- Install Forman
git clone https://github.com/ampvchen/toolsdev-project-2021-09-28.git
bundle install
bundle rails db:setup
bundle rails db:seed
- This command will setup all of the locations.
- Set
WEATHERAPI_KEY
bundle exec rake weather:init
- This will pull one month of weather data for all of the locations created in your seeds file.
bundle exec foreman start
Local Env variables:
- WEATHERAPI_KEY: Get an API key here
- SIDEKIQ_PASSWORD: This is for the Basic Auth in production
- SNITCHER_TOKEN: This is used to monitor the
weather:update
task
This is set in the .env
file for local development. More info here.
The weather data is updated through clockwork and configured in the config/clock.rb
file.
This can be manually run with: bundle exec clockwork config/clock.rb
Run rails tests
Tests are all written using MiniTest and Fixtures to keep dependencies low
-
/locations
- Show all available locations
-
/locations/#{:id}
- Get information about a specific location
-
/locations/#{:id}/temperatures
- Get all of the historical and forecast hourly temperatures in 2 arrays
- [0]: Historical data
- [1]: Forecast data
-
/locations/#{:id}/temperatures/high_low
- Get the high and low temperatures grouped by 3 hours blocks
- [0]: High data
- [1]: Lows data
-
/locations/#{:id}/temperatures/daily_average
- Get the average temperatures for each day
-
Timezones
- Everything is standardized on UTC
- The time should automatically be updated based on the Timezone
- Timezone data should be stored on the Location
-
Caching
- Since the
forcast.json
API request proxies the call to the [https://www.worldweatheronline.com/developer/api/docs/local-city-town-weather-api.aspx] the requests could be cached for that request over the hour before it becomes stale.
- Since the
-
Exception handling
- The Weather API silently fails and should raise an exception to be handled
-
weather:update
- When updating the weather, it pulls all the data for the day. It would be better to only fetch and store the relevant hour data.