|
7 | 7 | import requests
|
8 | 8 | from django.conf import settings
|
9 | 9 | from rest_framework import status
|
| 10 | +from rest_framework.request import Request |
10 | 11 | from rest_framework.response import Response
|
11 | 12 |
|
12 | 13 | from sentry import features
|
|
20 | 21 |
|
21 | 22 | logger = logging.getLogger(__name__)
|
22 | 23 |
|
23 |
| -from rest_framework.request import Request |
24 |
| - |
25 | 24 |
|
26 | 25 | def send_translate_request(
|
27 | 26 | org_id: int, org_slug: str, project_ids: list[int], natural_language_query: str
|
@@ -69,12 +68,14 @@ def post(request: Request, organization: Organization) -> Response:
|
69 | 68 | Request to translate a natural language query into a sentry EQS query.
|
70 | 69 | """
|
71 | 70 | if not request.user.is_authenticated:
|
72 |
| - return Response(status=status.HTTP_400_BAD_REQUEST) |
| 71 | + return Response( |
| 72 | + {"detail": "User is not authenticated"}, |
| 73 | + status=status.HTTP_400_BAD_REQUEST, |
| 74 | + ) |
73 | 75 |
|
74 | 76 | project_ids = [int(x) for x in request.data.get("project_ids", [])]
|
75 | 77 | natural_language_query = request.data.get("natural_language_query")
|
76 | 78 | limit = request.data.get("limit", 1)
|
77 |
| - use_flyout = request.data.get("use_flyout", True) |
78 | 79 |
|
79 | 80 | if len(project_ids) == 0 or not natural_language_query:
|
80 | 81 | return Response(
|
@@ -109,15 +110,6 @@ def post(request: Request, organization: Organization) -> Response:
|
109 | 110 | organization.id, organization.slug, project_ids, natural_language_query
|
110 | 111 | )
|
111 | 112 |
|
112 |
| - # XXX: This is a fallback to support the old response format until we fully support using multiple queries on the frontend |
113 |
| - if "responses" in data and use_flyout: |
114 |
| - if not data["responses"]: |
115 |
| - logger.info("No results found for query") |
116 |
| - return Response( |
117 |
| - {"detail": "No results found for query"}, |
118 |
| - status=status.HTTP_404_NOT_FOUND, |
119 |
| - ) |
120 |
| - data = data["responses"][0] |
121 | 113 | if "responses" not in data:
|
122 | 114 | return Response(
|
123 | 115 | {
|
|
0 commit comments