Skip to content
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

Remove-once-frequency #142

Merged
merged 4 commits into from
Aug 19, 2024
Merged

Remove-once-frequency #142

merged 4 commits into from
Aug 19, 2024

Conversation

EduardSchwarzkopf
Copy link
Owner

@EduardSchwarzkopf EduardSchwarzkopf commented Aug 19, 2024

Summary by Sourcery

Remove the 'ONCE' frequency option from both the codebase and the database, including updating the relevant function logic and adding a migration script.

Enhancements:

  • Remove the 'ONCE' frequency option from the Frequency enum in the codebase.

Deployment:

  • Add a new Alembic migration script to remove the 'ONCE' frequency from the database.

Copy link
Contributor

sourcery-ai bot commented Aug 19, 2024

Reviewer's Guide by Sourcery

This pull request removes the 'ONCE' frequency option from the application. The changes include updating the Frequency enum, modifying the logic for handling scheduled transactions, and adding a database migration to remove the 'once' frequency from the database.

File-Level Changes

Files Changes
app/utils/enums.py Removed 'ONCE' from the Frequency enum
app/repository.py Updated the get_period_start_date function to remove the case for Frequency.ONCE
alembic/versions/9694a1dffec2_remove_frequency_once_from_database.py Added a new Alembic migration to remove the 'once' frequency from the database

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:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @EduardSchwarzkopf - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider implementing a downgrade function in the migration file to make this change reversible if needed.
  • Ensure that all parts of the system that might have used the 'ONCE' frequency have been updated and tested thoroughly to prevent any potential breaks in functionality.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟡 Security: 1 issue found
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.execute(f" DELETE FROM {Frequency.__tablename__} WHERE label = 'once'")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚨 suggestion (security): Use parameterized queries instead of f-strings for SQL execution

While f-strings work here, it's safer to use parameterized queries to prevent potential SQL injection vulnerabilities. Consider using SQLAlchemy's text() function with bind parameters for this operation.

Suggested change
op.execute(f" DELETE FROM {Frequency.__tablename__} WHERE label = 'once'")
from sqlalchemy import text
from app.models import Frequency
op.execute(
text("DELETE FROM :table WHERE label = :label"),
{"table": Frequency.__tablename__, "label": "once"}
)

@EduardSchwarzkopf EduardSchwarzkopf merged commit a1c74a4 into main Aug 19, 2024
5 checks passed
@EduardSchwarzkopf EduardSchwarzkopf deleted the remove-once-frequency branch August 19, 2024 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant