Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def assertResolvedFromCommit(self, group, commit):
assert GroupLink.objects.filter(
group_id=group.id, linked_type=GroupLink.LinkedType.commit, linked_id=commit.id
).exists()
assert Group.objects.filter(
id=group.id, status=GroupStatus.RESOLVED, resolved_at__isnull=False
).exists()
data={
"event_id": "b" * 32,
"timestamp": iso_format(before_now(seconds=1)),
"fingerprint": ["group-2"],
"tags": {"foo": "bar"},
"environment": self.environment.name,
},
project_id=project.id,
)
target = event1.group
other = event2.group
with self.tasks():
merge_groups([other.id], target.id)
assert not Group.objects.filter(id=other.id).exists()
def update_aggregate_scenario(runner):
group = Group.objects.filter(project=runner.default_project).first()
runner.request(method="PUT", path="/issues/%s/" % group.id, data={"status": "unresolved"})
def get_queryset(self, request, organization, member, project_list):
return (
Group.objects.filter(groupseen__user=member.user, groupseen__project__in=project_list)
.extra(select={"sort_by": "sentry_groupseen.last_seen"})
.order_by("-sort_by")
)
@scenario("RetrieveAggregate")
def retrieve_aggregate_scenario(runner):
group = Group.objects.filter(project=runner.default_project).first()
runner.request(method="GET", path="/issues/%s/" % group.id)
date_from=None,
date_to=None,
):
start_time = time.time()
from sentry.models import Group, GroupStatus, GroupSubscription
search_filters = search_filters if search_filters is not None else []
# ensure projects are from same org
if len({p.organization_id for p in projects}) != 1:
raise RuntimeError("Cross organization search not supported")
if paginator_options is None:
paginator_options = {}
group_queryset = Group.objects.filter(project__in=projects).exclude(
status__in=[
GroupStatus.PENDING_DELETION,
GroupStatus.DELETION_IN_PROGRESS,
GroupStatus.PENDING_MERGE,
]
)
qs_builder_conditions = {
"status": QCallbackCondition(lambda status: Q(status=status)),
"bookmarked_by": QCallbackCondition(
lambda user: Q(bookmark_set__project__in=projects, bookmark_set__user=user)
),
"assigned_to": QCallbackCondition(
functools.partial(assigned_to_filter, projects=projects)
),
"unassigned": QCallbackCondition(
def isolated_project(self, project_name):
from sentry.models import Group
project = self.utils.create_project(project_name, teams=[self.default_team], org=self.org)
release = self.utils.create_release(project=project, user=self.me)
self.utils.create_event(project=project, release=release, platform="python")
self.utils.create_event(project=project, release=release, platform="java")
try:
yield project
finally:
# Enforce safe cascades into Group
Group.objects.filter(project=project).delete()
project.delete()
def _get_unresolved_count(self, project):
queryset = Group.objects.filter(
status=GroupStatus.UNRESOLVED,
project=project,
)
resolve_age = project.get_option('sentry:resolve_age', None)
if resolve_age:
queryset = queryset.filter(
last_seen__gte=timezone.now() - timedelta(hours=int(resolve_age)),
)
return queryset.count()
def update_aggregate_scenario(runner):
group = Group.objects.filter(project=runner.default_project).first()
runner.request(method='PUT', path='/issues/%s/' % group.id, data={'status': 'unresolved'})
def collect_project_platforms(**kwargs):
now = timezone.now()
min_project_id = 0
max_project_id = Project.objects.aggregate(x=Max("id"))["x"] or 0
step = 1000
while min_project_id <= max_project_id:
queryset = (
Group.objects.filter(
last_seen__gte=now - timedelta(days=1),
project__gte=min_project_id,
project__lt=min_project_id + step,
platform__isnull=False,
)
.values_list("platform", "project_id")
.distinct()
)
for platform, project_id in queryset:
platform = platform.lower()
if platform not in VALID_PLATFORMS:
continue
ProjectPlatform.objects.create_or_update(
project_id=project_id, platform=platform, values={"last_seen": now}
)