Skip to content

Commit

Permalink
Merge pull request #142 from EduardSchwarzkopf/remove-once-frequency
Browse files Browse the repository at this point in the history
Remove-once-frequency
  • Loading branch information
EduardSchwarzkopf authored Aug 19, 2024
2 parents 07b8965 + c446716 commit a1c74a4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""remove frequency once from database
Revision ID: 9694a1dffec2
Revises: dbce8a11ecc2
Create Date: 2024-08-19 06:33:39.007768
"""

from typing import Sequence, Union

from alembic import op
from app.models import Frequency

# revision identifiers, used by Alembic.
revision: str = "9694a1dffec2"
down_revision: Union[str, None] = "dbce8a11ecc2"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


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


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion app/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ async def get_scheduled_transactions_by_frequency(

def get_period_start_date(frequency_id: int) -> datetime:
match frequency_id:
case Frequency.DAILY.value | Frequency.ONCE.value:
case Frequency.DAILY.value:
return today
case Frequency.WEEKLY.value:
return today - timedelta(days=7)
Expand Down
1 change: 0 additions & 1 deletion app/utils/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class DatabaseFilterOperator(ExtendedEnum):


class Frequency(ExtendedEnum):
ONCE = 1
DAILY = 2
WEEKLY = 3
MONTHLY = 4
Expand Down
2 changes: 1 addition & 1 deletion tests/api/test_api_scheduled_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@pytest.mark.parametrize(
"amount, reference, category_id, frequency_id",
[
(10, "Added 10", 1, 1),
(10, "Added 10", 1, 2),
(20.5, "Added 20.5", 3, 2),
(-30.5, "Substract 30.5", 6, 3),
(-40.5, "Subsctract 40.5", 6, 4),
Expand Down

0 comments on commit a1c74a4

Please sign in to comment.