Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
armenzg committed Nov 15, 2024
1 parent a8d4e42 commit 444110a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/sentry/api/helpers/group_index/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def update_groups(
# we need to update this to find the release for each project (we shouldn't assume
# it's the same)
try:
release = most_recent_release(projects[0], commit)
release = most_recent_release_matching_commit(projects, commit)
res_type = GroupResolution.Type.in_release
res_status = GroupResolution.Status.resolved
except IndexError:
Expand Down Expand Up @@ -715,17 +715,25 @@ def get_release_to_resolve_by(project: Project) -> Release | None:
return release


def most_recent_release(project: Project, commit: Commit | None = None) -> Release | None:
queryset = Release.objects.filter(projects=project, organization_id=project.organization_id)
if commit:
queryset = queryset.filter(releasecommit__commit=commit)
def most_recent_release(project: Project) -> Release | None:
return (
queryset.extra(select={"sort": "COALESCE(date_released, date_added)"})
Release.objects.filter(projects=project, organization_id=project.organization_id)
.extra(select={"sort": "COALESCE(date_released, date_added)"})
.order_by("-sort")
.first()
)


def most_recent_release_matching_commit(
projects: Sequence[Project], commit: Commit
) -> Release | None:
return (
Release.objects.filter(projects__in=projects, releasecommit__commit=commit)
.extra(select={"sort": "COALESCE(date_released, date_added)"})
.order_by("-sort")[0]
)


def greatest_semver_release(project: Project) -> Release | None:
return get_semver_releases(project).first()

Expand Down

0 comments on commit 444110a

Please sign in to comment.