Skip to content

Commit

Permalink
Show chat's feedbacks (#512)
Browse files Browse the repository at this point in the history
* show chats feedbacks filtered

* return queryset as response
  • Loading branch information
Pranshu1902 authored May 14, 2024
1 parent 1323bfc commit c29dae8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions ayushma/views/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class ChatViewSet(
"list_all": ChatDetailSerializer,
"converse": ConverseSerializer,
"speech_to_text": SpeechToTextSerializer,
"feedbacks": ChatFeedbackSerializer,
}
permission_classes = (IsTempTokenOrAuthenticated,)
lookup_field = "external_id"
Expand Down Expand Up @@ -98,6 +99,18 @@ def perform_create(self, serializer):
serializer.save(user=self.request.user, project=project)
super().perform_create(serializer)

@extend_schema(
tags=("chats",),
)
@action(detail=True, methods=["get"])
def feedbacks(self, *args, **kwarg):
q = ChatFeedback.objects.filter(chat_message__chat__external_id=kwarg["external_id"])
serialized_data = ChatFeedbackSerializer(q, many=True).data
return Response(
{"data": serialized_data},
status=status.HTTP_200_OK,
)

@extend_schema(
tags=("chats",),
)
Expand Down

0 comments on commit c29dae8

Please sign in to comment.