def calculate_funnel(self, request: request.Request) -> Dict[str, Any]: team = self.team filter = Filter(request=request, data={"insight": INSIGHT_FUNNELS}, team=self.team) if filter.funnel_viz_type == FunnelVizType.TRENDS: return {"result": ClickhouseFunnelTrends(team=team, filter=filter).run()} elif filter.funnel_viz_type == FunnelVizType.TIME_TO_CONVERT: return {"result": ClickhouseFunnelTimeToConvert(team=team, filter=filter).run()} else: funnel_order_class = get_funnel_order_class(filter) return {"result": funnel_order_class(team=team, filter=filter).run()}
def _calculate_funnel(filter: Filter, key: str, team_id: int) -> List[Dict[str, Any]]: team = Team(pk=team_id) if filter.funnel_viz_type == FunnelVizType.TRENDS: result = ClickhouseFunnelTrends(team=team, filter=filter).run() elif filter.funnel_viz_type == FunnelVizType.TIME_TO_CONVERT: result = ClickhouseFunnelTimeToConvert(team=team, filter=filter).run() else: funnel_order_class = get_funnel_order_class(filter) result = funnel_order_class(team=team, filter=filter).run() return result
def __init__(self, filter: Filter, team: Team) -> None: super().__init__(filter, team) self.funnel_order = get_funnel_order_class(filter)(filter, team)
def test_filter_missing_order(self): filter = Filter({"foo": "bar"}) self.assertEqual(get_funnel_order_class(filter), ClickhouseFunnel)
def test_ordered(self): filter = Filter({"funnel_order_type": FunnelOrderType.ORDERED}) self.assertEqual(get_funnel_order_class(filter), ClickhouseFunnel)
def test_strict(self): filter = Filter({"funnel_order_type": FunnelOrderType.STRICT}) self.assertEqual(get_funnel_order_class(filter), ClickhouseFunnelStrict)