Skip to content

Commit

Permalink
fix(types): Fix group type index to be integer (#23316)
Browse files Browse the repository at this point in the history
Fix group type index to be integer
  • Loading branch information
webjunkie authored Jun 28, 2024
1 parent 8fc2b15 commit a023ee6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
29 changes: 25 additions & 4 deletions frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3217,19 +3217,33 @@
"type": "array"
},
"aggregation_group_type_index": {
"type": "number"
"type": "integer"
},
"breakdown": {
"$ref": "#/definitions/BreakdownKeyType"
},
"breakdown_group_type_index": {
"type": ["number", "null"]
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
]
},
"breakdown_hide_other_aggregation": {
"type": ["boolean", "null"]
},
"breakdown_limit": {
"type": "integer"
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
]
},
"breakdown_normalize_url": {
"type": "boolean"
Expand Down Expand Up @@ -4054,7 +4068,14 @@
"additionalProperties": false,
"properties": {
"group_type_index": {
"type": ["number", "null"]
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
]
},
"key": {
"type": "string"
Expand Down
23 changes: 13 additions & 10 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ import type {
} from './queries/schema'
import { NodeKind } from './queries/schema'

// Type alias for number to be reflected as integer in json-schema.
/** @asType integer */
type integer = number

export type Optional<T, K extends string | number | symbol> = Omit<T, K> & { [K in keyof T]?: T[K] }

// Keep this in sync with backend constants/features/{product_name}.yml
Expand Down Expand Up @@ -751,7 +755,7 @@ export interface CohortPropertyFilter extends BasePropertyFilter {

export interface GroupPropertyFilter extends BasePropertyFilter {
type: PropertyFilterType.Group
group_type_index?: number | null
group_type_index?: integer | null
operator: PropertyOperator
}

Expand Down Expand Up @@ -1037,7 +1041,7 @@ export type EntityFilter = {
export interface ActionFilter extends EntityFilter {
math?: string
math_property?: string
math_group_type_index?: number | null
math_group_type_index?: integer | null
math_hogql?: string
properties?: AnyPropertyFilter[]
type: EntityType
Expand Down Expand Up @@ -1139,7 +1143,7 @@ export interface GroupActorType extends CommonActorType {
/** Group key. */
id: string
group_key: string
group_type_index: number
group_type_index: integer
}

export type ActorType = PersonActorType | GroupActorType
Expand All @@ -1164,7 +1168,7 @@ export interface CohortCriteriaType {
value: BehavioralFilterType
type: BehavioralFilterKey
operator?: PropertyOperator | null
group_type_index?: number | null
group_type_index?: integer | null
event_type?: TaxonomicFilterGroupType | null
operator_value?: PropertyFilterValue
time_value?: number | string | null
Expand Down Expand Up @@ -2120,11 +2124,10 @@ export interface FilterType {
breakdown?: BreakdownKeyType
breakdown_normalize_url?: boolean
breakdowns?: Breakdown[]
breakdown_group_type_index?: number | null
breakdown_group_type_index?: integer | null
breakdown_hide_other_aggregation?: boolean | null
/** @asType integer */
breakdown_limit?: number | null
aggregation_group_type_index?: number // Groups aggregation
breakdown_limit?: integer | null
aggregation_group_type_index?: integer // Groups aggregation
}

export interface PropertiesTimelineFilterType {
Expand Down Expand Up @@ -2765,7 +2768,7 @@ export interface MultivariateFlagOptions {
export interface FeatureFlagFilters {
groups: FeatureFlagGroupType[]
multivariate: MultivariateFlagOptions | null
aggregation_group_type_index?: number | null
aggregation_group_type_index?: integer | null
payloads: Record<string, JsonType>
super_groups?: FeatureFlagGroupType[]
}
Expand Down Expand Up @@ -3118,7 +3121,7 @@ export interface Experiment {
recommended_sample_size?: number
feature_flag_variants: MultivariateFlagVariant[]
custom_exposure_filter?: FilterType
aggregation_group_type_index?: number
aggregation_group_type_index?: integer
}
start_date?: string | null
end_date?: string | null
Expand Down
6 changes: 3 additions & 3 deletions posthog/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2028,7 +2028,7 @@ class GroupPropertyFilter(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
group_type_index: Optional[float] = None
group_type_index: Optional[int] = None
key: str
label: Optional[str] = None
operator: PropertyOperator
Expand Down Expand Up @@ -3750,9 +3750,9 @@ class FilterType(BaseModel):
extra="forbid",
)
actions: Optional[list[dict[str, Any]]] = None
aggregation_group_type_index: Optional[float] = None
aggregation_group_type_index: Optional[int] = None
breakdown: Optional[Union[str, float, list[Union[str, float]]]] = None
breakdown_group_type_index: Optional[float] = None
breakdown_group_type_index: Optional[int] = None
breakdown_hide_other_aggregation: Optional[bool] = None
breakdown_limit: Optional[int] = None
breakdown_normalize_url: Optional[bool] = None
Expand Down

0 comments on commit a023ee6

Please sign in to comment.