Skip to content

Commit

Permalink
fix(similarity): Change backfill endpoint to use group id (#74508)
Browse files Browse the repository at this point in the history
Change similarity backfill endpoint to use group id instead of group
index
  • Loading branch information
jangjodi committed Jul 18, 2024
1 parent d6ea0d7 commit d152e91
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ def post(self, request: Request, project) -> Response:

# needs to either be a superuser or be in single org mode

last_processed_index = None
last_processed_id = None
only_delete = False
if request.data.get("last_processed_index"):
last_processed_index = int(request.data["last_processed_index"])
if request.data.get("last_processed_id"):
last_processed_id = int(request.data["last_processed_id"])

if request.data.get("only_delete"):
only_delete = True

backfill_seer_grouping_records_for_project.delay(
current_project_id=project.id,
last_processed_group_index_input=last_processed_index,
last_processed_group_id_input=last_processed_id,
only_delete=only_delete,
)
return Response(status=204)
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def test_post_not_superuser(self, mock_is_active_superuser):
"sentry.api.endpoints.project_backfill_similar_issues_embeddings_records.backfill_seer_grouping_records_for_project.delay"
)
@with_feature("projects:similarity-embeddings-backfill")
def test_post_success_no_last_processed_index(
def test_post_success_no_last_processed_id(
self, mock_backfill_seer_grouping_records, mock_is_active_superuser
):
response = self.client.post(self.url, data={})
assert response.status_code == 204, response.content
mock_backfill_seer_grouping_records.assert_called_with(
current_project_id=self.project.id,
last_processed_group_index_input=None,
last_processed_group_id_input=None,
only_delete=False,
)

Expand All @@ -57,14 +57,14 @@ def test_post_success_no_last_processed_index(
)
@with_feature("projects:similarity-embeddings-backfill")
@override_settings(SENTRY_SINGLE_ORGANIZATION=True)
def test_post_success_no_last_processed_index_single_org(
def test_post_success_no_last_processed_id_single_org(
self, mock_backfill_seer_grouping_records
):
response = self.client.post(self.url, data={})
assert response.status_code == 204, response.content
mock_backfill_seer_grouping_records.assert_called_with(
current_project_id=self.project.id,
last_processed_group_index_input=None,
last_processed_group_id_input=None,
only_delete=False,
)

Expand All @@ -76,14 +76,14 @@ def test_post_success_no_last_processed_index_single_org(
"sentry.api.endpoints.project_backfill_similar_issues_embeddings_records.backfill_seer_grouping_records_for_project.delay"
)
@with_feature("projects:similarity-embeddings-backfill")
def test_post_success_last_processed_index(
def test_post_success_last_processed_id(
self, mock_backfill_seer_grouping_records, mock_is_active_superuser
):
response = self.client.post(self.url, data={"last_processed_index": "8"})
response = self.client.post(self.url, data={"last_processed_id": "8"})
assert response.status_code == 204, response.content
mock_backfill_seer_grouping_records.assert_called_with(
current_project_id=self.project.id,
last_processed_group_index_input=8,
last_processed_group_id_input=8,
only_delete=False,
)

Expand All @@ -99,11 +99,11 @@ def test_post_success_only_delete(
self, mock_backfill_seer_grouping_records, mock_is_active_superuser
):
response = self.client.post(
self.url, data={"last_processed_index": "8", "only_delete": "true"}
self.url, data={"last_processed_id": "8", "only_delete": "true"}
)
assert response.status_code == 204, response.content
mock_backfill_seer_grouping_records.assert_called_with(
current_project_id=self.project.id,
last_processed_group_index_input=8,
last_processed_group_id_input=8,
only_delete=True,
)

0 comments on commit d152e91

Please sign in to comment.