Skip to content

Commit

Permalink
api for help details
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyanshs7 committed Sep 10, 2024
1 parent 8a7a375 commit 6df4b54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/spotlight/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
"""
from django.urls import path

from apps.spotlight.views import QueryView, RecentQueryView
from apps.spotlight.views import HelpQueryView, QueryView, RecentQueryView



urlpatterns = [
path('recent_queries/', RecentQueryView.as_view(), name='recent-queries'),
path('query/', QueryView.as_view(), name='query'),
path('help/', HelpQueryView.as_view(), name='help'),
]
10 changes: 9 additions & 1 deletion apps/spotlight/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from apps.spotlight.models import Query
from apps.spotlight.serializers import QuerySerializer

from .service import QueryService
from .service import HelpService, QueryService


# Create your views here.
Expand Down Expand Up @@ -69,3 +69,11 @@ def post(self, request, *args, **kwargs):
user_id=1
)
return JsonResponse(data=suggestions["suggestions"])


class HelpQueryView(generics.CreateAPIView):
def post(self, request, *args, **kwargs):
payload = json.loads(request.body)
user_query = payload["query"]
support_response = HelpService.get_support_response(user_query=user_query)
return JsonResponse(data={"message": support_response})

0 comments on commit 6df4b54

Please sign in to comment.