From d6090a10efc10163a555b57def18dce368444ad1 Mon Sep 17 00:00:00 2001 From: DongwookKim0823 Date: Sun, 15 Dec 2024 00:23:51 +0900 Subject: [PATCH] =?UTF-8?q?Fix=20:=20=EB=8F=99=EC=9D=BC=ED=95=9C=20?= =?UTF-8?q?=EA=B0=95=EC=95=84=EC=A7=80=EA=B0=80=20=EB=8F=99=EC=9D=BC?= =?UTF-8?q?=ED=95=9C=20=EB=82=A0=EC=A7=9C=EC=97=90=20=EB=8B=A4=EB=A5=B8=20?= =?UTF-8?q?=EC=9D=B4=EC=9A=A9=EA=B6=8C=EC=9C=BC=EB=A1=9C=20=EC=98=88?= =?UTF-8?q?=EC=95=BD=EB=90=98=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reservations/selectors/reservations.py | 28 +++++++++++-------- mung_manager_commons | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/mung_manager/reservations/selectors/reservations.py b/mung_manager/reservations/selectors/reservations.py index e29c442..4795dea 100644 --- a/mung_manager/reservations/selectors/reservations.py +++ b/mung_manager/reservations/selectors/reservations.py @@ -1,4 +1,5 @@ from collections import defaultdict +from datetime import timedelta from typing import Annotated, Any, Optional from django.db import connection @@ -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, diff --git a/mung_manager_commons b/mung_manager_commons index 15852ee..7b7a78f 160000 --- a/mung_manager_commons +++ b/mung_manager_commons @@ -1 +1 @@ -Subproject commit 15852ee7fa817a1e304d9dc4c823aa3ac618225b +Subproject commit 7b7a78f1868d777183a1365e9e18bd3cc403a98e