Skip to content

Commit

Permalink
style: apply formatter changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Makcal committed Oct 12, 2024
1 parent ba538d3 commit 76ad316
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2024-10-13 01:30:18.842558
"""

from collections import defaultdict
from typing import Sequence, Union

Expand All @@ -20,11 +21,7 @@


def fetch_order_data(s: Session, order_id: int):
order_data = s.execute(
select(column("room_id"))
.select_from(table("orders"))
.where(column("id") == order_id)
).one()
order_data = s.execute(select(column("room_id")).select_from(table("orders")).where(column("id") == order_id)).one()
executors = s.execute(
select(column("user_id"), column("order_number"))
.select_from(table("executors"))
Expand All @@ -35,14 +32,13 @@ def fetch_order_data(s: Session, order_id: int):

def clone_order(s: Session, order_data, executors):
new_order_id = s.scalar(
insert(table("orders", column('room_id')))
.values(room_id=order_data[0])
.returning(column('id'))
insert(table("orders", column("room_id"))).values(room_id=order_data[0]).returning(column("id"))
)
s.execute(
insert(table("executors", column("user_id"), column("order_id"), column("order_number")))
.values(order_id=new_order_id),
[{"user_id": e[0], "order_number": e[1]} for e in executors]
insert(table("executors", column("user_id"), column("order_id"), column("order_number"))).values(
order_id=new_order_id
),
[{"user_id": e[0], "order_number": e[1]} for e in executors],
)
return new_order_id

Expand All @@ -51,9 +47,7 @@ def upgrade() -> None:
with Session(bind=op.get_bind()) as session:
periodic_tasks: defaultdict[int, list[int]] = defaultdict(list)
pairs = session.execute(
select(column("id"), column("order_id"))
.select_from(table("tasks"))
.where(column("order_id").isnot(None))
select(column("id"), column("order_id")).select_from(table("tasks")).where(column("order_id").isnot(None))
).all()
for task_id, order_id in pairs:
periodic_tasks[order_id].append(task_id)
Expand All @@ -69,7 +63,7 @@ def upgrade() -> None:
.values(order_id=new_order_id)
.where(column("id") == task_id)
)

# same for manual tasks
manual_tasks: defaultdict[int, list[int]] = defaultdict(list)
pairs = session.execute(
Expand Down
3 changes: 2 additions & 1 deletion src/api/routes/bot/manual_task/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from sqlalchemy.sql.functions import count

from src.api.exceptions import (
TooManyTasksException, ManualTaskIsInactiveException,
TooManyTasksException,
ManualTaskIsInactiveException,
)
from src.api.utils import (
ROOM_DEPENDENCY,
Expand Down

0 comments on commit 76ad316

Please sign in to comment.