Skip to content

Commit

Permalink
Fix code quality points
Browse files Browse the repository at this point in the history
  • Loading branch information
Twixes committed Aug 21, 2024
1 parent 88a97d5 commit cf40215
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .storybook/app-context.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
import { MOCK_DEFAULT_TEAM, MOCK_DEFAULT_PROJECT } from 'lib/api.mock'
import { AppContext } from '~/types'

export const getStorybookAppContext = (): AppContext => ({
anonymous: false,
// Ideally we wouldn't set `current_team` here, the same way we don't set `current_user`, but unfortunately
// as of March 2024, a bunch of logics make the assumption that this is set, via `AppConfig`
current_team: MOCK_DEFAULT_TEAM,
current_project: MOCK_DEFAULT_PROJECT,
current_user: undefined as any, // `undefined` triggers a fetch and lets us mock the data
default_event_name: '$pageview',
persisted_feature_flags: [],
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/lib/api.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
PluginConfigWithPluginInfo,
PluginInstallationType,
PluginType,
ProjectType,
PropertyFilterType,
PropertyOperator,
TeamType,
Expand Down Expand Up @@ -90,6 +91,13 @@ export const MOCK_DEFAULT_TEAM: TeamType = {
live_events_token: '123',
}

export const MOCK_DEFAULT_PROJECT: ProjectType = {
id: MOCK_TEAM_ID,
name: 'MockHog App + Marketing',
organization_id: MOCK_ORGANIZATION_ID,
created_at: '2020-06-30T09:53:35.932534Z',
}

export const MOCK_DEFAULT_ORGANIZATION: OrganizationType = {
customer_id: null,
id: MOCK_ORGANIZATION_ID,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ export interface SessionRecordingAIConfig {
export interface ProjectType {
id: number
name: string
organization_id: number
organization_id: string
created_at: string
}
export interface TeamType extends TeamBasicType {
Expand Down
8 changes: 4 additions & 4 deletions posthog/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ class Project(models.Model):

objects: ProjectManager = ProjectManager()

@cached_property
def passthrough_team(self) -> "Team":
return self.teams.get(pk=self.pk)

def __str__(self):
if self.name:
return self.name
return str(self.pk)

__repr__ = sane_repr("id", "name")

@cached_property
def passthrough_team(self) -> "Team":
return self.teams.get(pk=self.pk)

0 comments on commit cf40215

Please sign in to comment.