ryansurf / cli-surf

Get surf and ocean data from the command line interface
MIT License
18 stars 30 forks source link

Feature: Add Historical Weather Data Comparison #152

Closed AITMAR-TAFE closed 1 week ago

AITMAR-TAFE commented 3 weeks ago

This pull request introduces a feature that enhances user experience by allowing users to compare current weather conditions with historical data from one year ago. This capability facilitates a better understanding of seasonal patterns, informs decision-making, and fosters awareness of climate trends. With versatile data presentation options through CLI prompts and a dedicated print function, users can access information in their preferred format. Comprehensive documentation and unit tests ensure clarity, maintainability, and reliability of the new functionality. Overall, this feature enriches user engagement and provides valuable insights into weather variability and its implications. Related to issue nr #148 .

Enhancements:

Implemented a two new function get_uv_history and ocean_information_history to fetch data one year ago. Refactored gather_data function to include historical weather data. Refactored arguments_dictionary , set_output_values and print_ocean_data for displaying past ocean data to maintain CLI prompt options. Created a separate print function print_historical_data for displaying historical data as default. Documented new functions and tests for clarity and maintainability.

Testing:

Added unit tests for the new functionality to ensure accuracy. These tests also confirm the functionality works as intended and adheres to expected outcomes.

Evidence of Implementation:

Screenshots: Included screenshot demonstrate how the feature looks in action. open-source-evidence

Summary by Sourcery

Add a feature to compare current weather conditions with historical data from one year ago, including UV index and ocean data. Implement new functions for fetching historical data and refactor existing functions to support this feature. Update documentation and add unit tests to ensure functionality and maintainability.

New Features:

Enhancements:

Documentation:

Tests:

sourcery-ai[bot] commented 3 weeks ago

Reviewer's Guide by Sourcery

This PR implements historical weather data comparison functionality by adding new API endpoints to fetch data from one year ago, extending existing functions to handle historical data, and creating new display functions. The implementation includes comprehensive error handling, testing capabilities through a testing flag, and proper data formatting.

Sequence diagram for fetching historical weather data

sequenceDiagram
    participant User
    participant CLI
    participant API
    participant OpenMeteo

    User->>CLI: Request historical weather data
    CLI->>API: Call gather_data with historical flag
    API->>OpenMeteo: Fetch UV history
    OpenMeteo-->>API: Return UV history data
    API->>OpenMeteo: Fetch ocean information history
    OpenMeteo-->>API: Return ocean information history
    API->>CLI: Return historical data
    CLI->>User: Display historical data

File-Level Changes

Change Details Files
Added new API endpoints for retrieving historical weather data
  • Created get_uv_history function to fetch UV index from one year ago
  • Created ocean_information_history function to fetch wave data from one year ago
  • Implemented date calculation logic to fetch data from exactly one year ago
  • Added testing flag for API response simulation
src/api.py
Extended data gathering and display functionality
  • Modified gather_data function to include historical weather data
  • Added new historical data fields to the output dictionary
  • Created print_historical_data function for displaying historical data
  • Updated arguments_dictionary with new CLI options for historical data display
src/helper.py
Added comprehensive test coverage for new functionality
  • Added tests for get_uv_history function
  • Added tests for ocean_information_history function
  • Added tests for print_historical_data function
  • Implemented tests for various edge cases and data types
tests/test_api.py
tests/test_helper.py

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 93.33333% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/api.py 93.33% 3 Missing :warning:
Files with missing lines Coverage Δ
src/helper.py 81.14% <ø> (ø)
src/api.py 94.56% <93.33%> (-0.40%) :arrow_down:
ryansurf commented 2 weeks ago

@all-contributors please add @AITMAR-TAFE for code

allcontributors[bot] commented 2 weeks ago

@ryansurf

I've put up a pull request to add @AITMAR-TAFE! :tada:

AITMAR-TAFE commented 2 weeks ago

Hey @ryansurf,

Thank you for your feedback! I appreciate your kind words about the changes and the testing implementation.

I did consider removing the default print function but hesitated because it was specified in my original issue. However, I have now fixed the issue that caused the linter to fail and removed the print function as you suggested. I also updated the user arguments and revised the README file to include instructions on retrieving all historical data arguments. Lastly, I added some tests for historcial data arguments to ensure everything works smooth.

Just let me know if there is anything else I can improve :) !

ryansurf commented 2 weeks ago

@AITMAR-TAFE just tested the changes, its working wonderfully!

Just an fyi, the linter failed again. However, this time its asking for the formatter to be ran, so I'll just merge the PR and take care of it on my end. Thats on me, I should have advised you to run that as well (make format)

Also, it would be nice to implement abbreviations for the arguments, like hide_direction / hdir. Just a thought though, feel free to ignore if you'd like

Regardless, great work! You've written clean, documented code with test cases. I really appreciate your efforts, thank you for the contribution

Edit: Actually, I'll wait a bit to merge it. If you want to run the formatter on your end, please do! If not, I'll merge the PR and do it myself in the next day or two 🥂

AITMAR-TAFE commented 1 week ago

Hey @ryansurf , thanks for the feedback, and apologies for the back and forth! I've now taken care of the formatter and added the suggested abbreviations for the arguments. I really appreciate you taking the time to review my work. Thanks again for the support!