From 06918a869e2cf26bf5b70218eafc117db9516699 Mon Sep 17 00:00:00 2001 From: che-hyeon Date: Tue, 27 May 2025 00:04:23 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20=EC=8B=9C=EA=B0=84=EB=B3=84=20=EC=9E=90?= =?UTF-8?q?=EB=8F=99=20=EC=84=B8=ED=8C=85=20=EC=84=A4=EC=A0=95=20=EB=B0=8F?= =?UTF-8?q?=20=EC=9E=85=EC=9E=A5=20=EC=99=84=EB=A3=8C=20=EC=8B=9C=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- accounts/tasks.py | 7 +++- booth/tasks.py | 7 ++++ waiting/views.py | 82 +++++++++++++++++++++++------------------------ 3 files changed, 54 insertions(+), 42 deletions(-) create mode 100644 booth/tasks.py diff --git a/accounts/tasks.py b/accounts/tasks.py index ebfb810..7642149 100644 --- a/accounts/tasks.py +++ b/accounts/tasks.py @@ -1,7 +1,12 @@ from celery import shared_task -from .models import CustomerUser +from .models import CustomerUser, SMSAuthenticate @shared_task def reset_no_show_num(): CustomerUser.objects.update(no_show_num=0) return "All no_show_num values reset to 0" + +@shared_task +def reset_bad_sms_count(): + SMSAuthenticate.objects.all().update(bad_sms_count=0) + return "All bad sms values reset to 0" \ No newline at end of file diff --git a/booth/tasks.py b/booth/tasks.py new file mode 100644 index 0000000..83d58a6 --- /dev/null +++ b/booth/tasks.py @@ -0,0 +1,7 @@ +from celery import shared_task +from .models import Booth + +@shared_task +def reset_no_show_num(): + Booth.objects.exclude(operating_status='not_started').update(operating_status='finished') + return "All operating_status reset to finished" \ No newline at end of file diff --git a/waiting/views.py b/waiting/views.py index 6641dc7..e94f4fc 100644 --- a/waiting/views.py +++ b/waiting/views.py @@ -723,47 +723,47 @@ def confirm_waiting(self, request, pk=None): except Exception as e: print("WebSocket send error (cancel):", str(e)) - entered_user_waitings = Waiting.objects.filter(user = waiting.user, waiting_status="waiting") - for w in entered_user_waitings: - w.waiting_status = "canceled" - w.save() - - waiting_team_cnt = Waiting.objects.filter(booth=w.booth, waiting_status='waiting').count() - entering_team_cnt = Waiting.objects.filter(booth=w.booth, waiting_status='entering').count() - entered_team_cnt = Waiting.objects.filter(booth=w.booth, waiting_status='entered').count() - canceled_team_cnt = (Waiting.objects.filter(booth=w.booth, waiting_status='canceled').count() + - Waiting.objects.filter(booth=w.booth, waiting_status='time_over').count()) - - try: - channel_layer = get_channel_layer() - admin_group_name = f"booth_{w.booth.booth_id}_admin" - async_to_sync(channel_layer.group_send)( - admin_group_name, - { - 'type': 'send_to_admin', - 'status': 'success', - 'message': '사용자가 대기를 취소했습니다.', - 'code': 200, - 'data': { - 'waiting_id': w.waiting_id, - 'waiting_status': w.waiting_status, - 'booth_info': { - 'waiting_team_cnt': waiting_team_cnt, - 'entering_team_cnt': entering_team_cnt, - 'entered_team_cnt': entered_team_cnt, - 'canceled_team_cnt': canceled_team_cnt - } - } - } - ) - except Exception as e: - print("WebSocket send error (cancel):", str(e)) - - sms_status_2 = "입장 준비해주세요." - self.sms_sending(w.booth, sms_status_2) - - # serializer = WaitingDetailSerializer(waiting) - # print(serializer.data) + # entered_user_waitings = Waiting.objects.filter(user = waiting.user, waiting_status="waiting") + # for w in entered_user_waitings: + # w.waiting_status = "canceled" + # w.save() + + # waiting_team_cnt = Waiting.objects.filter(booth=w.booth, waiting_status='waiting').count() + # entering_team_cnt = Waiting.objects.filter(booth=w.booth, waiting_status='entering').count() + # entered_team_cnt = Waiting.objects.filter(booth=w.booth, waiting_status='entered').count() + # canceled_team_cnt = (Waiting.objects.filter(booth=w.booth, waiting_status='canceled').count() + + # Waiting.objects.filter(booth=w.booth, waiting_status='time_over').count()) + + # try: + # channel_layer = get_channel_layer() + # admin_group_name = f"booth_{w.booth.booth_id}_admin" + # async_to_sync(channel_layer.group_send)( + # admin_group_name, + # { + # 'type': 'send_to_admin', + # 'status': 'success', + # 'message': '사용자가 대기를 취소했습니다.', + # 'code': 200, + # 'data': { + # 'waiting_id': w.waiting_id, + # 'waiting_status': w.waiting_status, + # 'booth_info': { + # 'waiting_team_cnt': waiting_team_cnt, + # 'entering_team_cnt': entering_team_cnt, + # 'entered_team_cnt': entered_team_cnt, + # 'canceled_team_cnt': canceled_team_cnt + # } + # } + # } + # ) + # except Exception as e: + # print("WebSocket send error (cancel):", str(e)) + + # sms_status_2 = "입장 준비해주세요." + # self.sms_sending(w.booth, sms_status_2) + + # # serializer = WaitingDetailSerializer(waiting) + # # print(serializer.data) return custom_response( data=None, message="대기가 입장되었습니다.",