jhanley634 / dojo-blackboard

An HTMX webserver for the Dojo's Tuesday night python meetups.
MIT License
3 stars 1 forks source link

16 faster plot #17

Closed jhanley634 closed 2 months ago

jhanley634 commented 2 months ago

Summary by Sourcery

Improve the performance of vehicle plotting by using a scatter plot and refactor API key handling to use a dictionary instead of a DataFrame. Enhance the IssPosition model with a method to convert instances to dictionaries and update tests accordingly.

Enhancements:

Tests:

sourcery-ai[bot] commented 2 months ago

Reviewer's Guide by Sourcery

This pull request optimizes the vehicle plotting functionality and improves the performance of API key handling. The main changes include refactoring the plot_agency_vehicles function, updating the get_recent_vehicle_journeys query, and replacing pandas with csv for API key reading.

File-Level Changes

Change Details Files
Optimized vehicle plotting functionality
  • Refactored plot_agency_vehicles function to use a list of dictionaries instead of plotting directly
  • Added a DataFrame creation step for more efficient plotting
  • Replaced individual plot calls with a single scatter plot
  • Updated color index calculation for smoother color transitions
  • Added timing information for performance tracking
src/bboard/transit/vehicles.py
Modified get_recent_vehicle_journeys query
  • Replaced limit parameter with a time-based filter
  • Updated query ordering for better performance
  • Removed unnecessary .all() call and used generator directly
src/bboard/transit/vehicles.py
Improved API key handling
  • Replaced pandas with csv module for reading API keys
  • Updated read_api_keys function to return a dictionary instead of a DataFrame
  • Modified get_api_key function to work with the new dictionary format
src/bboard/util/credentials.py
tests/credentials_test.py
src/bboard/util/credential_env_vars.py
Added _asdict method to Base class
  • Implemented _asdict method in Base class using SQLAlchemy's inspect
  • Added a test case for the new _asdict method
src/bboard/models/iss_position.py
tests/iss_test.py
Updated transit periodic update function
  • Removed 'CT' agency from the main list
  • Added a separate call to store_vehicle_journeys for 'CT' agency
src/bboard/util/lifespan_mgmt.py

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.