Skip to content

Commit

Permalink
Optimize team getter
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Aug 2, 2024
1 parent 6ebf107 commit 6c5f0d6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions posthog/api/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ def team_id(self) -> int:

@cached_property
def team(self) -> Team:
team_from_token = self._get_team_from_request()
if team_from_token:
return team_from_token

if self._is_project_view:
return Team.objects.get(
id=self.project_id # KLUDGE: This is just for the period of transition to project environments
)

team_from_token = self._get_team_from_request()
if team_from_token:
return team_from_token

if self.param_derived_from_user_current_team == "team_id":
user = cast(User, self.request.user)
team = user.team
Expand Down

0 comments on commit 6c5f0d6

Please sign in to comment.