diff --git a/src/sentry/models/projectteam.py b/src/sentry/models/projectteam.py index 7c2ad432a0090e..dd54eb0e58d86c 100644 --- a/src/sentry/models/projectteam.py +++ b/src/sentry/models/projectteam.py @@ -2,7 +2,7 @@ from typing import TYPE_CHECKING, ClassVar from django.db import router, transaction -from django.db.models import QuerySet, prefetch_related_objects +from django.db.models import QuerySet from django.db.models.signals import post_delete, post_save from sentry.backup.scopes import RelocationScope @@ -16,14 +16,12 @@ class ProjectTeamManager(BaseManager["ProjectTeam"]): def get_for_teams_with_org_cache(self, teams: Sequence["Team"]) -> QuerySet["ProjectTeam"]: - project_teams = ( + return ( self.filter(team__in=teams, project__status=ObjectStatus.ACTIVE) .order_by("project__name", "project__slug") .select_related("project") + .prefetch_related("project__organization") ) - prefetch_related_objects(project_teams, "project__organization") - - return project_teams @region_silo_model