-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(62) Show air quality alerts and 3-day forecast for selected zone #29
Commits on Oct 7, 2024
-
Add list of zones as static json
These are the forecast zones supported by the CERC API, which we will offer to the user on the forecast page.
Configuration menu - View commit details
-
Copy full SHA for d8eda46 - Browse repository at this point
Copy the full SHA d8eda46View commit details -
We will use this library to make calls to the CERC API in our client.
Configuration menu - View commit details
-
Copy full SHA for 310a07e - Browse repository at this point
Copy the full SHA 310a07eView commit details -
Add client for fetching forecast data from CERC API
To facilitate this, I have moved the sample forecast into the test fixtures, and added two new environment variables, CERC_API_HOST_URL and CERC_API_KEY.
Configuration menu - View commit details
-
Copy full SHA for e9844da - Browse repository at this point
Copy the full SHA e9844daView commit details -
Move from forecasts#index -> forecasts#show method
We have agree that this method is rendering a single, three day forecast at a time, therefore it should be a show rather than an index method, and forecast should be singular in the path.
Configuration menu - View commit details
-
Copy full SHA for b26164a - Browse repository at this point
Copy the full SHA b26164aView commit details -
Update forecast page with live data and zone form
Users can now select a zone and fetch live data for that zone from the CERC API
Configuration menu - View commit details
-
Copy full SHA for 49380f5 - Browse repository at this point
Copy the full SHA 49380f5View commit details -
Turn off fingerprinting of assets in test env
This is so we can load styles more easily when debugging a Capybara integration test which is saved to a local file e.g. with `#save_and_open_page`.
Configuration menu - View commit details
-
Copy full SHA for 2f959a6 - Browse repository at this point
Copy the full SHA 2f959a6View commit details -
Add WebMock gem to stub CERC API
This [mocking library][] will allow us to stub the HTTP response from CERC which our `CercApiClient` receives. We'll use it to set up scenarios for our integration tests. [mocking library]: https://github.com/bblimke/webmock
Configuration menu - View commit details
-
Copy full SHA for e951d8d - Browse repository at this point
Copy the full SHA e951d8dView commit details -
Describe 'View Air Quality Alerts' journey in int. test
We have two scenarios: 1. "View air quality alerts": we see an alert with a different warning status for each of the 3 days included in the forecast 2. "See confirmation that there are current no air quality alert": We see that there are no alerts We introduce three test helper modules: 1. a `Fixtures` module to build Forecasts for our tests 2. a `HttpStub` module to set WebMock stubs on HTTP traffic 3. an `AirQualitySteps` module to manage the implementation details for each "step" in the test. In our `view_air_quality_alerts_spec.rb` feature spec we ["include"][] this module in order to have access to its methods. This leaves the acceptance test clean and focused on describing the expected behaviour. ["include"]: https://ruby-doc.org/docs/ruby-doc-bundle/ProgrammingRuby/book/classes.html#UC
Configuration menu - View commit details
-
Copy full SHA for ba5eabf - Browse repository at this point
Copy the full SHA ba5eabfView commit details -
Configuration menu - View commit details
-
Copy full SHA for cfeb99f - Browse repository at this point
Copy the full SHA cfeb99fView commit details -
Confirm 'No air quality alerts' when 0 alerts found
One of our 2 acceptance tests now passes (albeit with a naive implementation in the controller!) ``` scenario "See confirmation that there are current no air quality alert" given_an_air_pollution_prediction_for_today_w_low_status and_an_air_pollution_prediction_for_tomorrow_w_low_warning_status and_an_air_pollution_prediction_for_day_after_tomorrow_w_low_warning_status and_the_response_from_cercs_api_is_stubbed_accordingly when_i_look_at_the_forecasts then_i_see_that_there_are_no_current_air_quality_alerts ```
Configuration menu - View commit details
-
Copy full SHA for 2c64f82 - Browse repository at this point
Copy the full SHA 2c64f82View commit details -
- stub environment variables - use an inline JSON fixture for clarity
Configuration menu - View commit details
-
Copy full SHA for dd53af8 - Browse repository at this point
Copy the full SHA dd53af8View commit details -
Stub CERC API for 'View forecasts' test
We implement a `ForecastSteps` module for our helper methods.
Configuration menu - View commit details
-
Copy full SHA for 0bfcaaf - Browse repository at this point
Copy the full SHA 0bfcaafView commit details -
Configuration menu - View commit details
-
Copy full SHA for ef2b0a7 - Browse repository at this point
Copy the full SHA ef2b0a7View commit details -
Add markup to aid semantics and testability
Each row in the table now has a class describing the information it carries: - `air-pollution` - `uv` - `pollen` - `temperature` Each of the "value cells" now has a [`data-*` attribute][] of `data-date` to identify which day's value it contains. This will allow our integration tests to be clear and maintainable. [`data-*` attribute]: https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes
Configuration menu - View commit details
-
Copy full SHA for 2a7d2e8 - Browse repository at this point
Copy the full SHA 2a7d2e8View commit details -
Configuration menu - View commit details
-
Copy full SHA for 00c5aa6 - Browse repository at this point
Copy the full SHA 00c5aa6View commit details -
Turn off deprecation warning in Rspec
I couldn't for now figure out how to resolve these warnings. I tried updating all gems to their latest versions. There isn't a more recent Ruby version to try. Come back to this later, maybe. ``` air-text/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/parsers/date_time_parser.rb:837: warning: statement not reached air-text/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/parsers/date_time_parser.rb:691: warning: assigned but unused variable - testEof air-text/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/parsers/address_lists_parser.rb:32457: warning: statement not reached air-text/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/parsers/address_lists_parser.rb:32618: warning: statement not reached air-text/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/parsers/address_lists_parser.rb:32654: warning: statement not reached air-text/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/parsers/address_lists_parser.rb:32743: warning: statement not reached air-text/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/parsers/address_lists_parser.rb:32759: warning: statement not reached air-text/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/parsers/address_lists_parser.rb:32825: warning: statement not reached air-text/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/parsers/address_lists_parser.rb:32866: warning: statement not reached air-text/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/parsers/address_lists_parser.rb:32891: warning: statement not reached air-text/vendor/bundle/ruby/3.3.0/gems/mail-2.8.1/lib/mail/parsers/address_lists_parser.rb:31987: warning: assigned but unused variable - testEof air-text/vendor/bundle/ruby/3.3.0/gems/sassc-rails-2.1.2/lib/sassc/rails/functions.rb:7: warning: method redefined; discarding old asset_data_url air-text/vendor/bundle/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/sass_processor.rb:274: warning: previous definition of asset_data_url was here air-text/vendor/bundle/ruby/3.3.0/gems/sassc-rails-2.1.2/lib/sassc/rails/compressor.rb:7: warning: method redefined; discarding old initialize air-text/vendor/bundle/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/sass_compressor.rb:39: warning: previous definition of initialize was here air-text/vendor/bundle/ruby/3.3.0/gems/sassc-rails-2.1.2/lib/sassc/rails/compressor.rb:17: warning: method redefined; discarding old call air-text/vendor/bundle/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/sass_compressor.rb:49: warning: previous definition of call was here air-text/vendor/bundle/ruby/3.3.0/gems/lograge-0.14.0/lib/lograge/log_subscribers/base.rb:44: warning: method redefined; discarding old extract_status air-text/vendor/bundle/ruby/3.3.0/gems/lograge-0.14.0/lib/lograge/log_subscribers/base.rb:41: warning: previous definition of extract_status was here air-text/vendor/bundle/ruby/3.3.0/gems/lograge-0.14.0/lib/lograge.rb:82: warning: method redefined; discarding old ignore_tests air-text/vendor/bundle/ruby/3.3.0/gems/lograge-0.14.0/lib/lograge.rb:28: warning: previous definition of ignore_tests was here air-text/vendor/bundle/ruby/3.3.0/gems/lograge-0.14.0/lib/lograge.rb:82: warning: method redefined; discarding old ignore_tests air-text/vendor/bundle/ruby/3.3.0/gems/lograge-0.14.0/lib/lograge.rb:28: warning: previous definition of ignore_tests was here ```
Configuration menu - View commit details
-
Copy full SHA for 9b3c4c9 - Browse repository at this point
Copy the full SHA 9b3c4c9View commit details -
Implement a ForecastFactory to build Forecast entities from CERC's API
We take a representation of a Forecast from CERC's API and build a list of our own Forecast entities. For now our ForecastBuilder only uses the first zone returned (i.e. only handles the scenario where we've asked CERC's API for information on a particular zone). We will likely develop this to handle all zones: that's what's returned if we don't request a specific zone e.g. ``` curl "https://cerc.example.com/getforecast/all?numdays=3 ``` For now we also leave out the rain and wind information as we aren't sure how/if/where this is needed.
Configuration menu - View commit details
-
Copy full SHA for f4dded0 - Browse repository at this point
Copy the full SHA f4dded0View commit details -
Add #inspect methods to forecast classes to aid debugging
`Forecast#inspect` will return a string representation like: ``` "#<Forecast @obtained_at=2024-10-02 15:38:00 +0100 @forecast_for=2024-10-02 @zone=#<ForecastZone @id=29 @name=Southwark @type=1> @air_pollution=#<AirPollutionPrediction @forecasted_at=2024-10-02 15:50:00 +0100 @nitrogen_dioxide=1> @particulate_matter_10=1 @particulate_matter_2_5=1 @ozone=2 @overall_score=2 @overall_label=LOW> @UV=2 @pollen=-999 @temperature=#<TemperaturePrediction @min=10.0 @max=16.6>> ```
Configuration menu - View commit details
-
Copy full SHA for 90946ba - Browse repository at this point
Copy the full SHA 90946baView commit details -
Configuration menu - View commit details
-
Copy full SHA for da08d6c - Browse repository at this point
Copy the full SHA da08d6cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 48885e9 - Browse repository at this point
Copy the full SHA 48885e9View commit details -
Configuration menu - View commit details
-
Copy full SHA for cec5ae8 - Browse repository at this point
Copy the full SHA cec5ae8View commit details -
Configuration menu - View commit details
-
Copy full SHA for cd38e0b - Browse repository at this point
Copy the full SHA cd38e0bView commit details -
Configuration menu - View commit details
-
Copy full SHA for f0b43a1 - Browse repository at this point
Copy the full SHA f0b43a1View commit details -
Move CERC API forecast fixtures into own namespace
We are going to build test fixtures for our own `Forecast` entities as distinct from the JSON representations which we receive from CERC's `/getforecast/all?` endpoint.
Configuration menu - View commit details
-
Copy full SHA for 49e7576 - Browse repository at this point
Copy the full SHA 49e7576View commit details -
We will implement these alerts properly in coming commits.
Configuration menu - View commit details
-
Copy full SHA for 24108e2 - Browse repository at this point
Copy the full SHA 24108e2View commit details -
Add factories to create test fixtures for domain forecasts
We need a way to build our `Forecast` domain entities (and their `AirPollutionPrediction`, `TemperaturePrediction`, `ForecastZone` component entities). We use [FactoryBot][] to help. [FactoryBot]: https://github.com/thoughtbot/factory_bot
Configuration menu - View commit details
-
Copy full SHA for 539da60 - Browse repository at this point
Copy the full SHA 539da60View commit details -
Configuration menu - View commit details
-
Copy full SHA for 628a046 - Browse repository at this point
Copy the full SHA 628a046View commit details -
Configuration menu - View commit details
-
Copy full SHA for 11c42a7 - Browse repository at this point
Copy the full SHA 11c42a7View commit details -
Configuration menu - View commit details
-
Copy full SHA for cc7b917 - Browse repository at this point
Copy the full SHA cc7b917View commit details -
Configuration menu - View commit details
-
Copy full SHA for deb404e - Browse repository at this point
Copy the full SHA deb404eView commit details -
Configuration menu - View commit details
-
Copy full SHA for b850e03 - Browse repository at this point
Copy the full SHA b850e03View commit details -
The DAQI scale is from 1 to 10: 1-3 = Low 4-6 = Moderate 7-9 = High 10 = Very high
Configuration menu - View commit details
-
Copy full SHA for cd831ba - Browse repository at this point
Copy the full SHA cd831baView commit details -
Configuration menu - View commit details
-
Copy full SHA for 54e56dd - Browse repository at this point
Copy the full SHA 54e56ddView commit details -
Configuration menu - View commit details
-
Copy full SHA for d860cc7 - Browse repository at this point
Copy the full SHA d860cc7View commit details -
Configuration menu - View commit details
-
Copy full SHA for e164907 - Browse repository at this point
Copy the full SHA e164907View commit details -
Configuration menu - View commit details
-
Copy full SHA for 9b013e0 - Browse repository at this point
Copy the full SHA 9b013e0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 7a691e3 - Browse repository at this point
Copy the full SHA 7a691e3View commit details -
Configuration menu - View commit details
-
Copy full SHA for b50a88d - Browse repository at this point
Copy the full SHA b50a88dView commit details -
Configuration menu - View commit details
-
Copy full SHA for dcc4815 - Browse repository at this point
Copy the full SHA dcc4815View commit details