Skip to content

Commit

Permalink
fix(hogql): Bring back cohort filter support in actors query (#22462)
Browse files Browse the repository at this point in the history
* fix(hogql): Bring back cohort filter support in actors query

* Update UI snapshots for `chromium` (1)

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and timgl committed May 24, 2024
1 parent fcdc070 commit 57ccaf1
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 27 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 21 additions & 18 deletions frontend/src/queries/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,9 @@
"additionalProperties": false,
"properties": {
"fixedProperties": {
"description": "Currently only person filters supported (including via HogQL), See `filter_conditions()` in actor_strategies.py.",
"description": "Currently only person filters supported. No filters for querying groups. See `filter_conditions()` in actor_strategies.py.",
"items": {
"anyOf": [
{
"$ref": "#/definitions/PersonPropertyFilter"
},
{
"$ref": "#/definitions/HogQLPropertyFilter"
}
]
"$ref": "#/definitions/AnyPersonScopeFilter"
},
"type": "array"
},
Expand All @@ -89,16 +82,9 @@
"type": "array"
},
"properties": {
"description": "Currently only person filters supported (including via HogQL). see `filter_conditions()` in actor_strategies.py.",
"description": "Currently only person filters supported. No filters for querying groups. See `filter_conditions()` in actor_strategies.py.",
"items": {
"anyOf": [
{
"$ref": "#/definitions/PersonPropertyFilter"
},
{
"$ref": "#/definitions/HogQLPropertyFilter"
}
]
"$ref": "#/definitions/AnyPersonScopeFilter"
},
"type": "array"
},
Expand Down Expand Up @@ -255,6 +241,23 @@
}
]
},
"AnyPersonScopeFilter": {
"anyOf": [
{
"$ref": "#/definitions/PersonPropertyFilter"
},
{
"$ref": "#/definitions/CohortPropertyFilter"
},
{
"$ref": "#/definitions/HogQLPropertyFilter"
},
{
"$ref": "#/definitions/EmptyPropertyFilter"
}
],
"description": "Any filter type supported by `property_to_expr(scope=\"person\", ...)`."
},
"AnyPropertyFilter": {
"anyOf": [
{
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
AnyPersonScopeFilter,
AnyPropertyFilter,
BaseMathType,
Breakdown,
Expand All @@ -13,7 +14,6 @@ import {
FunnelsFilterType,
GroupMathType,
HogQLMathType,
HogQLPropertyFilter,
InsightShortId,
InsightType,
IntervalType,
Expand Down Expand Up @@ -990,10 +990,10 @@ export interface ActorsQuery extends DataNode<ActorsQueryResponse> {
source?: InsightActorsQuery | FunnelsActorsQuery | FunnelCorrelationActorsQuery | HogQLQuery
select?: HogQLExpression[]
search?: string
/** Currently only person filters supported (including via HogQL). see `filter_conditions()` in actor_strategies.py. */
properties?: (PersonPropertyFilter | HogQLPropertyFilter)[]
/** Currently only person filters supported (including via HogQL), See `filter_conditions()` in actor_strategies.py. */
fixedProperties?: (PersonPropertyFilter | HogQLPropertyFilter)[]
/** Currently only person filters supported. No filters for querying groups. See `filter_conditions()` in actor_strategies.py. */
properties?: AnyPersonScopeFilter[]
/** Currently only person filters supported. No filters for querying groups. See `filter_conditions()` in actor_strategies.py. */
fixedProperties?: AnyPersonScopeFilter[]
orderBy?: string[]
limit?: integer
offset?: integer
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,13 @@ export type AnyPropertyFilter =
| DataWarehousePropertyFilter
| DataWarehousePersonPropertyFilter

/** Any filter type supported by `property_to_expr(scope="person", ...)`. */
export type AnyPersonScopeFilter =
| PersonPropertyFilter
| CohortPropertyFilter
| HogQLPropertyFilter
| EmptyPropertyFilter

export type AnyFilterLike = AnyPropertyFilter | PropertyGroupFilter | PropertyGroupFilterValue

export type SessionRecordingId = SessionRecordingType['id']
Expand Down
12 changes: 8 additions & 4 deletions posthog/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4134,9 +4134,11 @@ class ActorsQuery(BaseModel):
model_config = ConfigDict(
extra="forbid",
)
fixedProperties: Optional[list[Union[PersonPropertyFilter, HogQLPropertyFilter]]] = Field(
fixedProperties: Optional[
list[Union[PersonPropertyFilter, CohortPropertyFilter, HogQLPropertyFilter, EmptyPropertyFilter]]
] = Field(
default=None,
description="Currently only person filters supported (including via HogQL), See `filter_conditions()` in actor_strategies.py.",
description="Currently only person filters supported. No filters for querying groups. See `filter_conditions()` in actor_strategies.py.",
)
kind: Literal["ActorsQuery"] = "ActorsQuery"
limit: Optional[int] = None
Expand All @@ -4145,9 +4147,11 @@ class ActorsQuery(BaseModel):
)
offset: Optional[int] = None
orderBy: Optional[list[str]] = None
properties: Optional[list[Union[PersonPropertyFilter, HogQLPropertyFilter]]] = Field(
properties: Optional[
list[Union[PersonPropertyFilter, CohortPropertyFilter, HogQLPropertyFilter, EmptyPropertyFilter]]
] = Field(
default=None,
description="Currently only person filters supported (including via HogQL). see `filter_conditions()` in actor_strategies.py.",
description="Currently only person filters supported. No filters for querying groups. See `filter_conditions()` in actor_strategies.py.",
)
response: Optional[ActorsQueryResponse] = None
search: Optional[str] = None
Expand Down

0 comments on commit 57ccaf1

Please sign in to comment.