|
2 | 2 |
|
3 | 3 | from copy import deepcopy
|
4 | 4 | from rest_framework.exceptions import PermissionDenied
|
5 |
| -import six |
6 |
| -from enum import Enum |
7 | 5 |
|
8 | 6 | from sentry import features
|
9 | 7 | from sentry.api.bases import OrganizationEndpoint, OrganizationEventsError
|
10 | 8 | from sentry.api.event_search import get_snuba_query_args, InvalidSearchQuery
|
11 | 9 | from sentry.models.project import Project
|
12 |
| -from sentry.utils import snuba |
13 | 10 |
|
14 | 11 | # We support 4 "special fields" on the v2 events API which perform some
|
15 | 12 | # additional calculations over aggregated event data
|
|
31 | 28 | ALLOWED_GROUPINGS = frozenset(('issue.id', 'project.id'))
|
32 | 29 |
|
33 | 30 |
|
34 |
| -class Direction(Enum): |
35 |
| - NEXT = 0 |
36 |
| - PREV = 1 |
37 |
| - |
38 |
| - |
39 | 31 | class OrganizationEventsEndpointBase(OrganizationEndpoint):
|
40 | 32 |
|
41 | 33 | def get_snuba_query_args(self, request, organization):
|
@@ -145,55 +137,3 @@ def get_snuba_query_args_v2(self, request, organization, params):
|
145 | 137 | raise OrganizationEventsError(
|
146 | 138 | 'Boolean search operator OR and AND not allowed in this search.')
|
147 | 139 | return snuba_args
|
148 |
| - |
149 |
| - def next_event_id(self, *args): |
150 |
| - """ |
151 |
| - Returns the next event ID if there is a subsequent event matching the |
152 |
| - conditions provided |
153 |
| - """ |
154 |
| - return self._get_next_or_prev_id(Direction.NEXT, *args) |
155 |
| - |
156 |
| - def prev_event_id(self, *args): |
157 |
| - """ |
158 |
| - Returns the previous event ID if there is a previous event matching the |
159 |
| - conditions provided |
160 |
| - """ |
161 |
| - return self._get_next_or_prev_id(Direction.PREV, *args) |
162 |
| - |
163 |
| - def _get_next_or_prev_id(self, direction, request, organization, snuba_args, event): |
164 |
| - if (direction == Direction.NEXT): |
165 |
| - time_condition = [ |
166 |
| - ['timestamp', '>=', event.timestamp], |
167 |
| - [['timestamp', '>', event.timestamp], ['event_id', '>', event.event_id]] |
168 |
| - ] |
169 |
| - orderby = ['timestamp', 'event_id'] |
170 |
| - start = max(event.datetime, snuba_args['start']) |
171 |
| - end = snuba_args['end'] |
172 |
| - |
173 |
| - else: |
174 |
| - time_condition = [ |
175 |
| - ['timestamp', '<=', event.timestamp], |
176 |
| - [['timestamp', '<', event.timestamp], ['event_id', '<', event.event_id]] |
177 |
| - ] |
178 |
| - orderby = ['-timestamp', '-event_id'] |
179 |
| - start = snuba_args['start'] |
180 |
| - end = min(event.datetime, snuba_args['end']) |
181 |
| - |
182 |
| - conditions = snuba_args['conditions'][:] |
183 |
| - conditions.extend(time_condition) |
184 |
| - |
185 |
| - result = snuba.raw_query( |
186 |
| - start=start, |
187 |
| - end=end, |
188 |
| - selected_columns=['event_id'], |
189 |
| - conditions=conditions, |
190 |
| - filter_keys=snuba_args['filter_keys'], |
191 |
| - orderby=orderby, |
192 |
| - limit=1, |
193 |
| - referrer='api.organization-events.next-or-prev-id', |
194 |
| - ) |
195 |
| - |
196 |
| - if 'error' in result or len(result['data']) == 0: |
197 |
| - return None |
198 |
| - |
199 |
| - return six.text_type(result['data'][0]['event_id']) |
0 commit comments