ampvchen / toolsdev-project-2021-09-28

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tools Dev Project

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.

Requirements

The list of requirements to install are:

  • Ruby >= 2.6.x
  • Postgresql
  • Redis

Note: Ruby 2.6.8 is required for Heroku (Support Runtimes).

Installation

  • 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

Configuration

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.

Updating the weather data

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

Tests

Run rails tests

Tests are all written using MiniTest and Fixtures to keep dependencies low

Endpoints

  • /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

Issues

  • 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

  • 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.

Built with

About


Languages

Language:Ruby 73.0%Language:HTML 20.1%Language:JavaScript 4.3%Language:CSS 2.6%