Skip to content

Commit

Permalink
type fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr committed Feb 14, 2024
1 parent f783f0c commit e197b28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
7 changes: 5 additions & 2 deletions posthog/hogql_queries/insights/funnels/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABC
from functools import cached_property
from typing import Any, Dict, List, Optional, Tuple, cast
from typing import Any, Dict, List, Optional, Tuple, Union, cast
import uuid
from posthog.clickhouse.materialized_columns.column import ColumnName
from posthog.constants import BREAKDOWN_VALUES_LIMIT
Expand All @@ -26,6 +26,7 @@
BreakdownType,
EventsNode,
FunnelExclusionActionsNode,
FunnelTimeToConvertResults,
StepOrderValue,
)
from posthog.types import EntityNode, ExclusionEntityNode
Expand Down Expand Up @@ -265,7 +266,9 @@ def _get_breakdown_expr(self) -> ast.Expr:
else:
raise ValidationError(detail=f"Unsupported breakdown type: {breakdownType}")

def _format_results(self, results) -> List[Dict[str, Any]] | List[List[Dict[str, Any]]]:
def _format_results(
self, results
) -> Union[FunnelTimeToConvertResults, List[Dict[str, Any]], List[List[Dict[str, Any]]]]:
breakdown = self.context.breakdown

if not results or len(results) == 0:
Expand Down
11 changes: 6 additions & 5 deletions posthog/hogql_queries/insights/funnels/funnel_time_to_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from posthog.hogql_queries.insights.funnels.base import FunnelBase
from posthog.hogql_queries.insights.funnels.funnel_query_context import FunnelQueryContext
from posthog.hogql_queries.insights.funnels.utils import get_funnel_order_class
from posthog.schema import FunnelTimeToConvertResults


class FunnelTimeToConvert(FunnelBase):
Expand All @@ -17,11 +18,11 @@ def __init__(

self.funnel_order = get_funnel_order_class(self.context.funnelsFilter)(context=self.context)

def _format_results(self, results: list) -> dict:
return {
"bins": [(bin_from_seconds, person_count) for bin_from_seconds, person_count, _ in results],
"average_conversion_time": results[0][2],
}
def _format_results(self, results: list) -> FunnelTimeToConvertResults:
return FunnelTimeToConvertResults(
bins=[[bin_from_seconds, person_count] for bin_from_seconds, person_count, _ in results],
average_conversion_time=results[0][2],
)

def get_query(self) -> ast.SelectQuery:
query, funnelsFilter = self.context.query, self.context.funnelsFilter
Expand Down

0 comments on commit e197b28

Please sign in to comment.