Skip to content

Fix: 관리자 대기 목록 정렬 수정#226

Merged
jiyoon607 merged 1 commit into
LINE-NOW:mainfrom
jiyoon607:main
May 22, 2025
Merged

Fix: 관리자 대기 목록 정렬 수정#226
jiyoon607 merged 1 commit into
LINE-NOW:mainfrom
jiyoon607:main

Conversation

@jiyoon607
Copy link
Copy Markdown
Contributor

@jiyoon607 jiyoon607 commented May 22, 2025

🔥 Pull requests

👷 작업한 내용

관리자 대기 목록 정렬 수정했습니다

  1. 대기중/입장중 -> 여기는 오랜된 순
  2. 취소된 대기 -> 여기는 최신 순
  3. 입장 완료 -> 여기는 최신 순

🚨 참고 사항

📸 스크린샷

🖥️ 주요 코드 설명

  • 정렬 부분 변경
@action(detail=False, methods=['get'], url_path='booth')
    def booth_waiting_list(self, request):
        # 로그인 확인
        if not request.user or not request.user.is_authenticated:
            return Response({
                "status": "error",
                "message": "인증이 필요합니다.",
                "code": 401,
                "data": [
                    {"detail": "유효한 access 토큰이 필요합니다."}
                ]
            }, status=status.HTTP_401_UNAUTHORIZED)
        # 관리자 여부 확인
        if not request.user.is_manager:
            return custom_response(
                data={'detail': "관리자 유저가 아닙니다."},
                message='권한이 없습니다.',
                code=403,
                success=False
            )

        try:
            booth = request.user.manager_user.booth
            
            # waiting_status가 기타인 경우: 오래된 순 정렬
            other_qs = Waiting.objects.filter(
                booth=booth
            ).exclude(
                waiting_status__in=['entered', 'canceled', 'time_over']
            ).annotate(
                status_priority=Value(0, output_field=IntegerField())
            ).order_by('created_at')

            # waiting_status가 canceled, time_over, entered: 최신 순 정렬
            status_qs = Waiting.objects.filter(
                booth=booth,
                waiting_status__in=['canceled', 'time_over', 'entered']
            ).annotate(
                status_priority=Case(
                    When(waiting_status__in=['canceled', 'time_over'], then=Value(1)),
                    When(waiting_status='entered', then=Value(2)),
                    output_field=IntegerField()
                )
            ).order_by('status_priority', '-created_at')

            # 병합
            queryset = list(chain(other_qs, status_qs))

            serializer = ManagerWaitingListSerializer(queryset, many=True)
            return custom_response(
                serializer.data, 
                message='관리자 부스 대기 조회 성공',
                code=status.HTTP_200_OK
            )
        except Exception as e:
            return custom_response(
                data={'detail': str(e)},
                message='관리자 부스 대기 조회 실패',
                code=status.HTTP_500_INTERNAL_SERVER_ERROR,
                success=False
            )

✅ Check List

  • Merge 대상 브랜치가 올바른가?
  • 최종 코드가 에러 없이 잘 동작하는가?

📟 관련 이슈

  • Resolved: #이슈번호

@jiyoon607 jiyoon607 merged commit 9a25826 into LINE-NOW:main May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant