Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ def backfill_metric_issue_detectorgroup(
# figure out the detector
latest_event = get_oldest_or_latest_event(group, EventOrdering.LATEST)
if not latest_event:
logger.info("No latest event found for group", extra={"group_id": group.id})
DetectorGroup.objects.create(
group_id=group.id,
detector_id=None,
)
logger.info(
"No latest event found for group, creating DetectorGroup with null detector",
extra={"group_id": group.id},
)
continue

occurrence = latest_event.occurrence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ def test_migration(self) -> None:
group=self.metric_issue_deleted_detector, detector=None
).exists()

assert not DetectorGroup.objects.filter(
group=self.metric_issue_no_occurrence
).exists() # does not exist because we should figure out what to do with this
assert DetectorGroup.objects.filter(
group=self.metric_issue_no_occurrence,
detector=None,
).exists()

assert DetectorGroup.objects.filter(
group=self.metric_issue_existing_detectorgroup, detector=self.detector2
Expand Down
Loading