Skip to content
Merged
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
16 changes: 15 additions & 1 deletion src/sentry/models/projectownership.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
from sentry import features
from sentry.db.models import Model, region_silo_only_model, sane_repr
from sentry.db.models.fields import FlexibleForeignKey, JSONField
from sentry.models import ActorTuple
from sentry.models import Activity, ActorTuple
from sentry.models.groupowner import OwnerRuleType
from sentry.models.project import Project
from sentry.ownership.grammar import Rule, load_schema, resolve_actors
from sentry.types.activity import ActivityType
from sentry.utils import metrics
from sentry.utils.cache import cache

Expand Down Expand Up @@ -287,6 +288,19 @@ def handle_auto_assignment(cls, project_id, event):
}
)

activity = Activity.objects.filter(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk much about the autoassignment feature, this was tricky to figure out so I hope it's right 😬 if it's not please point me towards how I can determine if an issue already has a manual assignment.

group=event.group, type=ActivityType.ASSIGNED.value
).order_by("-datetime")
if activity:
auto_assigned = activity[0].data.get("integration")
if not auto_assigned:
analytics.record(
"autoassignment.post_manual_assignment",
organization_id=event.group.project.organization_id,
project_id=project_id,
group_id=event.group.id,
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about just returning early here now - initially I thought we'd gather metrics first and then stop auto-assigning when it's already been manually assigned, but we can still gather metrics for when we would have done it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be ok with this too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll just merge this for now and go back tomorrow to return early and write a test 😎

assignment = GroupAssignee.objects.assign(
event.group,
owner,
Expand Down