|
@@ -7,6 +7,7 @@ from sentry import features
|
|
|
from sentry.models import Activity, Group, GroupStatus
|
|
|
from sentry.signals import issue_resolved
|
|
|
from sentry.tasks.base import instrumented_task
|
|
|
+from sentry.types.activity import ActivityType
|
|
|
from sentry.utils.suspect_resolutions import ALGO_VERSION, analytics
|
|
|
from sentry.utils.suspect_resolutions.commit_correlation import is_issue_commit_correlated
|
|
|
from sentry.utils.suspect_resolutions.metric_correlation import is_issue_error_rate_correlated
|
|
@@ -35,11 +36,25 @@ def record_suspect_resolutions(
|
|
|
@instrumented_task(name="sentry.tasks.get_suspect_resolutions", queue="get_suspect_resolutions")
|
|
|
def get_suspect_resolutions(resolved_issue_id: int) -> Sequence[int]:
|
|
|
resolved_issue = Group.objects.get(id=resolved_issue_id)
|
|
|
- resolution_type = (
|
|
|
- Activity.objects.filter(group=resolved_issue).values_list("type", flat=True).first()
|
|
|
+ latest_resolved_activity = (
|
|
|
+ Activity.objects.filter(
|
|
|
+ group=resolved_issue,
|
|
|
+ type__in=(
|
|
|
+ ActivityType.SET_RESOLVED.value,
|
|
|
+ ActivityType.SET_RESOLVED_IN_COMMIT.value,
|
|
|
+ ActivityType.SET_RESOLVED_IN_PULL_REQUEST.value,
|
|
|
+ ActivityType.SET_RESOLVED_IN_RELEASE.value,
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ .order_by("-datetime")
|
|
|
+ .values_list("type", flat=True)
|
|
|
+ .first()
|
|
|
+ )
|
|
|
+ latest_resolved_activity_type = (
|
|
|
+ ActivityType(latest_resolved_activity).name if latest_resolved_activity else None
|
|
|
)
|
|
|
|
|
|
- if resolved_issue.status != GroupStatus.RESOLVED or resolution_type is None:
|
|
|
+ if resolved_issue.status != GroupStatus.RESOLVED or latest_resolved_activity is None:
|
|
|
return []
|
|
|
|
|
|
suspect_issue_candidates = list(
|
|
@@ -72,7 +87,7 @@ def get_suspect_resolutions(resolved_issue_id: int) -> Sequence[int]:
|
|
|
algo_version=ALGO_VERSION,
|
|
|
resolved_group_id=resolved_issue.id,
|
|
|
candidate_group_id=metric_correlation_result.candidate_suspect_resolution_id,
|
|
|
- resolved_group_resolution_type=resolution_type,
|
|
|
+ resolved_group_resolution_type=latest_resolved_activity_type,
|
|
|
pearson_r_coefficient=metric_correlation_result.coefficient,
|
|
|
pearson_r_start_time=result.correlation_start_time,
|
|
|
pearson_r_end_time=result.correlation_end_time,
|