DEpt-metagenom / MetagenoMongo

1 stars 2 forks source link

flask:2024-08-27 #28

Closed iwmstjp closed 2 months ago

iwmstjp commented 2 months ago

Summary by Sourcery

Refactor the Flask application to improve security by using a random secret key, enhance error handling with a defaultdict for errors, and update the email notification system to support multiple recipients. Add a README.md file with setup instructions.

New Features:

Enhancements:

Documentation:

sourcery-ai[bot] commented 2 months ago

Reviewer's Guide by Sourcery

This pull request implements several important changes to improve the security, error handling, and functionality of the Flask application. Key modifications include updating the secret key generation, implementing environment variable checks, refactoring error handling, enhancing email notifications, and improving data validation.

File-Level Changes

Change Details Files
Improved secret key generation and environment variable handling
  • Replaced static secret key with dynamically generated one using os.urandom()
  • Added checks for required environment variables (META_REMOTE_PATH and META_KEY_PATH)
  • Implemented a function to check for RECIPIENT_EMAIL environment variable
flask-version/metagenomongo/app.py
Refactored error handling and reporting
  • Replaced 'results' list with a defaultdict called 'errors' for more structured error handling
  • Updated error reporting in various functions to use the new 'errors' structure
  • Modified templates to display errors based on the new structure
flask-version/metagenomongo/app.py
flask-version/metagenomongo/module/validation.py
flask-version/metagenomongo/templates/index_with_table.html
flask-version/metagenomongo/templates/index.html
Enhanced email notification system
  • Updated email sending function to accept file name and remote path as parameters
  • Implemented support for multiple recipients
  • Added more detailed email content including file name and upload location
flask-version/metagenomongo/module/email.py
flask-version/metagenomongo/app.py
Improved data validation
  • Added validation for unique combinations of sampleID, run_directory, and barcode
  • Updated error reporting in validation functions to use the new 'errors' structure
flask-version/metagenomongo/module/validation.py
Added README.md with setup and usage instructions
  • Included steps for cloning the repository, installing dependencies, setting environment variables, and running the application
  • Added optional instructions for using the remote server file saving function
flask-version/metagenomongo/README.md

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.