Browse Source

fix(similarity): cohort backfill pr adjustments (#73126)

follow ups from https://github.com/getsentry/sentry/pull/73075
Josh Ferge 8 months ago
parent
commit
9d03adef66

+ 6 - 6
src/sentry/tasks/embeddings_grouping/backfill_seer_grouping_records_for_project.py

@@ -90,10 +90,10 @@ def backfill_seer_grouping_records_for_project(
         return
 
     if only_delete:
-        delete_seer_grouping_records(project.id, redis_client)
+        delete_seer_grouping_records(current_project_id, redis_client)
         logger.info(
             "backfill_seer_grouping_records.deleted_all_records",
-            extra={"current_project_id": project.id},
+            extra={"current_project_id": current_project_id},
         )
         call_next_backfill(
             last_processed_group_index=None,
@@ -178,7 +178,7 @@ def backfill_seer_grouping_records_for_project(
         logger.info(
             "backfill_seer_grouping_records.seer_down",
             extra={
-                "current_project_id": project.id,
+                "current_project_id": current_project_id,
                 "last_processed_project_index": last_processed_project_index,
             },
         )
@@ -258,12 +258,12 @@ def call_next_backfill(
             return
 
         if isinstance(cohort, str):
-            cohort_list = settings.SIMILARITY_BACKFILL_COHORT_MAP.get(cohort, [])
+            cohort_projects = settings.SIMILARITY_BACKFILL_COHORT_MAP.get(cohort, [])
         else:
-            cohort_list = cohort
+            cohort_projects = cohort
 
         batch_project_id, last_processed_project_index = get_project_for_batch(
-            last_processed_project_index, cohort_list, cohort
+            last_processed_project_index, cohort_projects
         )
 
         if batch_project_id is None:

+ 5 - 5
src/sentry/tasks/embeddings_grouping/utils.py

@@ -514,10 +514,10 @@ def delete_seer_grouping_records(
         Group.objects.bulk_update(groups_with_seer_metadata, ["data"])
 
 
-def get_project_for_batch(last_processed_project_index, cohort_list, cohort_name):
-    next_cohort_index = last_processed_project_index + 1
-    if next_cohort_index >= len(cohort_list):
+def get_project_for_batch(last_processed_project_index, cohort_projects):
+    next_project_index = last_processed_project_index + 1
+    if next_project_index >= len(cohort_projects):
         return None, None
-    project_id = cohort_list[next_cohort_index]
-    last_processed_project_index = next_cohort_index
+    project_id = cohort_projects[next_project_index]
+    last_processed_project_index = next_project_index
     return project_id, last_processed_project_index