Skip to content

Commit

Permalink
Fix #102 - 동일한 강아지가 동일한 날짜에 다른 이용권으로 예약되는 문제 (#103)
Browse files Browse the repository at this point in the history
- 동일한 강아지가 동일한 날짜에 다른 이용권으로 예약되는 문제 수정

Close #102
  • Loading branch information
DongwookKim0823 authored Dec 14, 2024
1 parent 8c7765b commit c087aba
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
28 changes: 16 additions & 12 deletions mung_manager/reservations/selectors/reservations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import defaultdict
from datetime import timedelta
from typing import Annotated, Any, Optional

from django.db import connection
Expand Down Expand Up @@ -318,21 +319,24 @@ def get_queryset_for_duplicate_reservation(
Returns:
list[str]: 예약 날짜 리스트를 반환하며, 존재하지 않을 경우 빈 리스트를 반환합니다.
"""
reserved_dates = (
Reservation.objects.filter(
customer_id=customer_id,
customer_pet_id=customer_pet_id,
pet_kindergarden_id=pet_kindergarden_id,
)
.exclude(
reservation_status=ReservationStatus.CANCELED.value,
)
.values_list("reserved_at", flat=True)
reservations = Reservation.objects.filter(
customer_id=customer_id,
customer_pet_id=customer_pet_id,
pet_kindergarden_id=pet_kindergarden_id,
).exclude(
reservation_status=ReservationStatus.CANCELED.value,
)

formatted_dates = [date.strftime("%Y-%m-%d") for date in reserved_dates]
formatted_dates = []
for reservation in reservations:
current_date = reservation.reserved_at.date()
end_date = reservation.end_at.date() # type: ignore

return formatted_dates
while current_date <= end_date:
formatted_dates.append(current_date.strftime("%Y-%m-%d"))
current_date += timedelta(days=1)

return list(set(formatted_dates))

def get_queryset_for_hotel_type_reservation(
self,
Expand Down
2 changes: 1 addition & 1 deletion mung_manager_commons

0 comments on commit c087aba

Please sign in to comment.