Browse Source

ref(most-helpful-event): Add 'recommended' endpoint (#54219)

Closes https://github.com/getsentry/sentry/issues/54199
Julia Hoge 1 year ago
parent
commit
2e61714cfd

+ 3 - 3
src/sentry/api/endpoints/group_event_details.py

@@ -121,7 +121,7 @@ class GroupEventDetailsEndpoint(GroupEndpoint):
         elif event_id == "oldest":
             with metrics.timer("api.endpoints.group_event_details.get", tags={"type": "oldest"}):
                 event = group.get_oldest_event_for_environments(environment_names)
-        elif event_id == "helpful":
+        elif event_id in ("helpful", "recommended"):
             if features.has(
                 "organizations:issue-details-most-helpful-event",
                 group.project.organization,
@@ -137,7 +137,7 @@ class GroupEventDetailsEndpoint(GroupEndpoint):
                             conditions = issue_search_query_to_conditions(
                                 query, group, request.user, environments
                             )
-                            event = group.get_helpful_event_for_environments(
+                            event = group.get_recommended_event_for_environments(
                                 environments, conditions
                             )
                         except ValidationError:
@@ -153,7 +153,7 @@ class GroupEventDetailsEndpoint(GroupEndpoint):
                         "api.endpoints.group_event_details.get",
                         tags={"type": "helpful", "query": False},
                     ):
-                        event = group.get_helpful_event_for_environments(environments)
+                        event = group.get_recommended_event_for_environments(environments)
             else:
                 return Response(status=404)
         else:

+ 1 - 1
src/sentry/api/urls.py

@@ -576,7 +576,7 @@ GROUP_URLS = [
         GroupEventsEndpoint.as_view(),
     ),
     re_path(
-        r"^(?P<issue_id>[^\/]+)/events/(?P<event_id>(?:latest|oldest|helpful|\d+|[A-Fa-f0-9-]{32,36}))/$",
+        r"^(?P<issue_id>[^\/]+)/events/(?P<event_id>(?:latest|oldest|helpful|recommended|\d+|[A-Fa-f0-9-]{32,36}))/$",
         GroupEventDetailsEndpoint.as_view(),
     ),
     re_path(

+ 3 - 3
src/sentry/models/group.py

@@ -240,7 +240,7 @@ def get_oldest_or_latest_event_for_environments(
     return None
 
 
-def get_helpful_event_for_environments(
+def get_recommended_event_for_environments(
     environments: Sequence[Environment],
     group: Group,
     conditions: Optional[Sequence[Condition]] = None,
@@ -721,12 +721,12 @@ class Group(Model):
             self,
         )
 
-    def get_helpful_event_for_environments(
+    def get_recommended_event_for_environments(
         self,
         environments: Sequence[Environment] = (),
         conditions: Optional[Sequence[Condition]] = None,
     ) -> GroupEvent | None:
-        maybe_event = get_helpful_event_for_environments(
+        maybe_event = get_recommended_event_for_environments(
             environments,
             self,
             conditions,

+ 5 - 3
tests/snuba/models/test_group.py

@@ -121,7 +121,8 @@ class GroupTestSnuba(TestCase, SnubaTestCase, PerformanceIssueTestCase, Occurren
 
         group = Group.objects.first()
         assert (
-            group.get_helpful_event_for_environments().event_id == event_all_helpful_params.event_id
+            group.get_recommended_event_for_environments().event_id
+            == event_all_helpful_params.event_id
         )
         assert (
             group.get_latest_event_for_environments().event_id == event_none_helpful_params.event_id
@@ -169,7 +170,8 @@ class GroupTestSnuba(TestCase, SnubaTestCase, PerformanceIssueTestCase, Occurren
         perf_group = transaction_event_1.group
 
         assert (
-            perf_group.get_helpful_event_for_environments().event_id == transaction_event_1.event_id
+            perf_group.get_recommended_event_for_environments().event_id
+            == transaction_event_1.event_id
         )
         assert (
             perf_group.get_latest_event_for_environments().event_id == transaction_event_1.event_id
@@ -214,7 +216,7 @@ class GroupTestSnuba(TestCase, SnubaTestCase, PerformanceIssueTestCase, Occurren
         group = Group.objects.first()
         group.update(type=ProfileFileIOGroupType.type_id)
 
-        group_event = group.get_helpful_event_for_environments()
+        group_event = group.get_recommended_event_for_environments()
         assert group_event.event_id == occurrence.event_id
         self.assert_occurrences_identical(group_event.occurrence, occurrence)