Skip to content

Commit

Permalink
Merge pull request #102 from dudtlstm/main
Browse files Browse the repository at this point in the history
  • Loading branch information
JongbeomLee623 authored Oct 7, 2024
2 parents 0150b71 + 512cceb commit ce10b1c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
3 changes: 1 addition & 2 deletions manager/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
path('manager/', include(booth_detail_router.urls)),
path('manager/login', AdminLoginView.as_view(), name='admin_login'),
path('manager/logout', AdminLogoutView.as_view(), name='admin_logout'),


path('manager/waiting-counts', WaitingCountView.as_view(), name='waiting_counts'),
# path('manager/waitings', BoothWaitingListView.as_view(), name='booth_waiting_list'),
# path('manager/waitings/status/<str:status_group>', BoothWaitingStatusFilterView.as_view(), name='booth_waiting_status_filter'),

Expand Down
25 changes: 25 additions & 0 deletions manager/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,28 @@ def resume(self, request, *args, **kwargs):
message="Booth waiting status changed to operating.",
code=status.HTTP_200_OK
)

# 상태별 웨이팅 개수 카운트
class WaitingCountView(APIView):
authentication_classes = [JWTAuthentication]
permission_classes = [IsAuthenticated, IsAdminUser]

def get(self, request):
admin = self.request.admin
booth = admin.booth

waiting_count = WaitingFilter({'status': 'waiting'}, queryset=Waiting.objects.filter(booth=booth)).qs.count()
calling_count = WaitingFilter({'status': 'calling'}, queryset=Waiting.objects.filter(booth=booth)).qs.count()
arrived_count = WaitingFilter({'status': 'arrived'}, queryset=Waiting.objects.filter(booth=booth)).qs.count()
canceled_count = WaitingFilter({'status': 'canceled'}, queryset=Waiting.objects.filter(booth=booth)).qs.count()

return custom_response(
data={
"waiting": waiting_count,
"calling": calling_count,
"arrived": arrived_count,
"canceled": canceled_count
},
message="Waiting counts fetched successfully",
code=status.HTTP_200_OK
)

0 comments on commit ce10b1c

Please sign in to comment.