Skip to content

Commit

Permalink
Merge branch 'master' into hog-to-js++
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra committed Dec 2, 2024
2 parents b6ac756 + 7b7e8ff commit 221eb65
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions posthog/hogql_queries/web_analytics/web_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def session_properties(self) -> ast.Expr:
return property_to_expr(properties, team=self.team, scope="event")

@cached_property
def conversion_goal_expr(self) -> ast.Expr:
def conversion_goal_expr(self) -> Optional[ast.Expr]:
if isinstance(self.query.conversionGoal, ActionConversionGoal):
action = Action.objects.get(pk=self.query.conversionGoal.actionId, team__project_id=self.team.project_id)
return action_to_expr(action)
Expand All @@ -109,10 +109,10 @@ def conversion_goal_expr(self) -> ast.Expr:
right=ast.Constant(value=self.query.conversionGoal.customEventName),
)
else:
return ast.Constant(value=None)
return None

@cached_property
def conversion_person_id_expr(self) -> ast.Expr:
def conversion_person_id_expr(self) -> Optional[ast.Expr]:
if self.conversion_goal_expr:
return ast.Call(
name="any",
Expand All @@ -128,7 +128,7 @@ def conversion_person_id_expr(self) -> ast.Expr:
],
)
else:
return ast.Constant(value=None)
return None

@cached_property
def pageview_count_expression(self) -> ast.Expr:
Expand All @@ -147,11 +147,11 @@ def pageview_count_expression(self) -> ast.Expr:
return ast.Call(name="count", args=[])

@cached_property
def conversion_count_expr(self) -> ast.Expr:
def conversion_count_expr(self) -> Optional[ast.Expr]:
if self.conversion_goal_expr:
return ast.Call(name="countIf", args=[self.conversion_goal_expr])
else:
return ast.Constant(value=None)
return None

@cached_property
def event_type_expr(self) -> ast.Expr:
Expand Down Expand Up @@ -196,13 +196,12 @@ def inner_select(self) -> ast.SelectQuery:
"date_range_end": end,
"event_properties": self.event_properties(),
"session_properties": self.session_properties(),
"conversion_person_id_expr": self.conversion_person_id_expr,
"event_type_expr": self.event_type_expr,
},
)
assert isinstance(parsed_select, ast.SelectQuery)

if self.query.conversionGoal:
if self.conversion_count_expr and self.conversion_person_id_expr:
parsed_select.select.append(ast.Alias(alias="conversion_count", expr=self.conversion_count_expr))
parsed_select.select.append(ast.Alias(alias="conversion_person_id", expr=self.conversion_person_id_expr))
else:
Expand Down

0 comments on commit 221eb65

Please sign in to comment.