Skip to content

Commit

Permalink
rename: services and routers
Browse files Browse the repository at this point in the history
  • Loading branch information
RezenkovD committed Sep 6, 2023
1 parent b5c5327 commit fa488cb
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 76 deletions.
56 changes: 28 additions & 28 deletions src/routers/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def read_group_history(
current_user: User = Depends(get_current_user),
group_id: int,
) -> Page[GroupHistory]:
return paginate(db, services.group_history(db, current_user.id, group_id))
return paginate(db, services.read_group_history(db, current_user.id, group_id))


@router.get("/{group_id}/info/", response_model=GroupInfo)
Expand Down Expand Up @@ -141,17 +141,17 @@ def read_group_total_expenses(
)
elif year_month:
filter_date = transform_date_or_422(year_month)
return services.group_total_expenses(
return services.read_group_total_expenses(
db, current_user.id, group_id, filter_date=filter_date
)
elif start_date and end_date:
start_date = transform_exact_date_or_422(start_date)
end_date = transform_exact_date_or_422(end_date)
return services.group_total_expenses(
return services.read_group_total_expenses(
db, current_user.id, group_id, start_date=start_date, end_date=end_date
)
else:
return services.group_total_expenses(db, current_user.id, group_id)
return services.read_group_total_expenses(db, current_user.id, group_id)


@router.get("/{group_id}/my-total-expenses/", response_model=GroupUserTotalExpenses)
Expand All @@ -176,17 +176,17 @@ def read_group_user_total_expenses(
)
elif year_month:
filter_date = transform_date_or_422(year_month)
return services.group_user_total_expenses(
return services.read_group_user_total_expenses(
db, current_user.id, group_id, filter_date=filter_date
)
elif start_date and end_date:
start_date = transform_exact_date_or_422(start_date)
end_date = transform_exact_date_or_422(end_date)
return services.group_user_total_expenses(
return services.read_group_user_total_expenses(
db, current_user.id, group_id, start_date=start_date, end_date=end_date
)
else:
return services.group_user_total_expenses(db, current_user.id, group_id)
return services.read_group_user_total_expenses(db, current_user.id, group_id)


@router.get("/{group_id}/users-spenders/", response_model=List[UserSpender])
Expand All @@ -211,17 +211,17 @@ def read_group_users_spenders(
)
elif year_month:
filter_date = transform_date_or_422(year_month)
return services.group_users_spenders(
return services.read_group_users_spenders(
db, current_user.id, group_id, filter_date=filter_date
)
elif start_date and end_date:
start_date = transform_exact_date_or_422(start_date)
end_date = transform_exact_date_or_422(end_date)
return services.group_users_spenders(
return services.read_group_users_spenders(
db, current_user.id, group_id, start_date=start_date, end_date=end_date
)
else:
return services.group_users_spenders(db, current_user.id, group_id)
return services.read_group_users_spenders(db, current_user.id, group_id)


@router.get("/{group_id}/category-expenses/", response_model=List[CategoryExpenses])
Expand All @@ -246,17 +246,17 @@ def read_group_category_expenses(
)
elif year_month:
filter_date = transform_date_or_422(year_month)
return services.group_category_expenses(
return services.read_group_category_expenses(
db, current_user.id, group_id, filter_date=filter_date
)
elif start_date and end_date:
start_date = transform_exact_date_or_422(start_date)
end_date = transform_exact_date_or_422(end_date)
return services.group_category_expenses(
return services.read_group_category_expenses(
db, current_user.id, group_id, start_date=start_date, end_date=end_date
)
else:
return services.group_category_expenses(db, current_user.id, group_id)
return services.read_group_category_expenses(db, current_user.id, group_id)


@router.get(
Expand Down Expand Up @@ -368,13 +368,13 @@ def read_group_member_info(
)
elif year_month:
filter_date = transform_date_or_422(year_month)
return services.group_member_info(
return services.read_group_member_info(
db, current_user.id, group_id, member_id, filter_date=filter_date
)
elif start_date and end_date:
start_date = transform_exact_date_or_422(start_date)
end_date = transform_exact_date_or_422(end_date)
return services.group_member_info(
return services.read_group_member_info(
db,
current_user.id,
group_id,
Expand All @@ -383,14 +383,14 @@ def read_group_member_info(
end_date=end_date,
)
else:
return services.group_member_info(db, current_user.id, group_id, member_id)
return services.read_group_member_info(db, current_user.id, group_id, member_id)


@router.get(
"/{group_id}/member/{member_id}/category-expenses/",
response_model=List[CategoryExpenses],
)
def read_group_category_expenses(
def read_group_member_category_expenses(
*,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
Expand All @@ -412,13 +412,13 @@ def read_group_category_expenses(
)
elif year_month:
filter_date = transform_date_or_422(year_month)
return services.group_member_category_expenses(
return services.read_group_member_category_expenses(
db, current_user.id, group_id, member_id, filter_date=filter_date
)
elif start_date and end_date:
start_date = transform_exact_date_or_422(start_date)
end_date = transform_exact_date_or_422(end_date)
return services.group_member_category_expenses(
return services.read_group_member_category_expenses(
db,
current_user.id,
group_id,
Expand All @@ -427,7 +427,7 @@ def read_group_category_expenses(
end_date=end_date,
)
else:
return services.group_member_category_expenses(
return services.read_group_member_category_expenses(
db, current_user.id, group_id, member_id
)

Expand Down Expand Up @@ -458,13 +458,13 @@ def read_group_member_daily_expenses(
)
elif year_month:
filter_date = transform_date_or_422(year_month)
return services.group_member_daily_expenses(
return services.read_group_member_daily_expenses(
db, current_user.id, group_id, member_id, filter_date=filter_date
)
elif start_date and end_date:
start_date = transform_exact_date_or_422(start_date)
end_date = transform_exact_date_or_422(end_date)
return services.group_member_daily_expenses(
return services.read_group_member_daily_expenses(
db,
current_user.id,
group_id,
Expand All @@ -473,7 +473,7 @@ def read_group_member_daily_expenses(
end_date=end_date,
)
else:
return services.group_member_daily_expenses(
return services.read_group_member_daily_expenses(
db, current_user.id, group_id, member_id
)

Expand Down Expand Up @@ -504,13 +504,13 @@ def read_group_member_daily_expenses_detail(
)
elif year_month:
filter_date = transform_date_or_422(year_month)
return services.group_member_daily_expenses_detail(
return services.read_group_member_daily_expenses_detail(
db, current_user.id, group_id, member_id, filter_date=filter_date
)
elif start_date and end_date:
start_date = transform_exact_date_or_422(start_date)
end_date = transform_exact_date_or_422(end_date)
return services.group_member_daily_expenses_detail(
return services.read_group_member_daily_expenses_detail(
db,
current_user.id,
group_id,
Expand All @@ -519,21 +519,21 @@ def read_group_member_daily_expenses_detail(
end_date=end_date,
)
else:
return services.group_member_daily_expenses_detail(
return services.read_group_member_daily_expenses_detail(
db, current_user.id, group_id, member_id
)


@router.get(
"/{group_id}/member/{member_id}/history/", response_model=Page[GroupHistory]
)
def read_group_history(
def read_group_member_history(
*,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
group_id: int,
member_id: int,
) -> Page[GroupHistory]:
return paginate(
db, services.group_member_history(db, current_user.id, group_id, member_id)
db, services.read_group_member_history(db, current_user.id, group_id, member_id)
)
16 changes: 8 additions & 8 deletions src/routers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def read_user_balance(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
) -> UserBalance:
return services.calculate_user_balance(db, current_user.id)
return services.read_user_balance(db, current_user.id)


@router.get("/info/", response_model=UserModel)
Expand All @@ -65,7 +65,7 @@ def read_user_history(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
) -> Page[UserHistory]:
return paginate(db, services.user_history(current_user.id))
return paginate(db, services.read_user_history(current_user.id))


@router.get("/{group_id}/expenses/", response_model=UserGroupExpenses)
Expand Down Expand Up @@ -199,20 +199,20 @@ def read_user_total_expenses(
)
elif year_month:
filter_date = transform_date_or_422(year_month)
return services.user_total_expenses(
return services.read_user_total_expenses(
db, current_user.id, filter_date=filter_date
)
elif start_date and end_date:
start_date = transform_exact_date_or_422(start_date)
end_date = transform_exact_date_or_422(end_date)
return services.user_total_expenses(
return services.read_user_total_expenses(
db,
current_user.id,
start_date=start_date,
end_date=end_date,
)
else:
return services.user_total_expenses(db, current_user.id)
return services.read_user_total_expenses(db, current_user.id)


@router.get("/total-replenishments/", response_model=UserTotalReplenishments)
Expand All @@ -235,17 +235,17 @@ def read_user_total_replenishments(
)
elif year_month:
filter_date = transform_date_or_422(year_month)
return services.user_total_replenishments(
return services.read_user_total_replenishments(
db, current_user.id, filter_date=filter_date
)
elif start_date and end_date:
start_date = transform_exact_date_or_422(start_date)
end_date = transform_exact_date_or_422(end_date)
return services.user_total_replenishments(
return services.read_user_total_replenishments(
db,
current_user.id,
start_date=start_date,
end_date=end_date,
)
else:
return services.user_total_replenishments(db, current_user.id)
return services.read_user_total_replenishments(db, current_user.id)
30 changes: 15 additions & 15 deletions src/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
)
from .user import (
get_user,
calculate_user_balance,
user_total_expenses,
user_total_replenishments,
user_history,
read_user_balance,
read_user_total_expenses,
read_user_total_replenishments,
read_user_history,
read_user_daily_expenses,
read_category_expenses,
read_group_expenses,
Expand All @@ -23,23 +23,23 @@
update_group,
disband_group,
leave_group,
remove_user,
read_categories_group,
read_user_groups,
read_users_group,
remove_user,
read_group_info,
group_history,
group_total_expenses,
group_user_total_expenses,
group_users_spenders,
group_category_expenses,
read_group_history,
read_group_total_expenses,
read_group_user_total_expenses,
read_group_users_spenders,
read_group_category_expenses,
read_group_daily_expenses,
read_group_daily_expenses_detail,
group_member_info,
group_member_category_expenses,
group_member_daily_expenses,
group_member_daily_expenses_detail,
group_member_history,
read_group_member_info,
read_group_member_category_expenses,
read_group_member_daily_expenses,
read_group_member_daily_expenses_detail,
read_group_member_history,
)
from .invitation import create_invitation, read_invitations, response_invitation
from .replenishment import (
Expand Down
Loading

0 comments on commit fa488cb

Please sign in to comment.