Ejemplo n.º 1
0
    def test_no_event_in_period(self):
        _create_person(distinct_ids=["user a"], team=self.team)

        _create_event(event="step one",
                      distinct_id="user a",
                      team=self.team,
                      timestamp="2021-06-06 21:00:00")

        filter = Filter(
            data={
                "insight":
                INSIGHT_FUNNELS,
                "display":
                TRENDS_LINEAR,
                "interval":
                "day",
                "date_from":
                "2021-06-07 00:00:00",
                "date_to":
                "2021-06-13 23:59:59",
                "funnel_window_days":
                7,
                "events": [
                    {
                        "id": "step one",
                        "order": 0
                    },
                    {
                        "id": "step two",
                        "order": 1
                    },
                    {
                        "id": "step three",
                        "order": 2
                    },
                ],
            })

        funnel_trends = ClickhouseFunnelTrends(filter, self.team,
                                               ClickhouseFunnel)
        results = funnel_trends.perform_query()

        self.assertEqual(len(results), 7)
Ejemplo n.º 2
0
    def test_only_one_user_reached_one_step(self):
        _create_person(distinct_ids=["user a"], team=self.team)

        _create_event(event="step one",
                      distinct_id="user a",
                      team=self.team,
                      timestamp="2021-06-07 19:00:00")
        filter = Filter(
            data={
                "insight":
                INSIGHT_FUNNELS,
                "display":
                TRENDS_LINEAR,
                "interval":
                "day",
                "date_from":
                "2021-06-07 00:00:00",
                "date_to":
                "2021-06-13 23:59:59",
                "funnel_window_days":
                7,
                "events": [
                    {
                        "id": "step one",
                        "order": 0
                    },
                    {
                        "id": "step two",
                        "order": 1
                    },
                    {
                        "id": "step three",
                        "order": 2
                    },
                ],
            })

        funnel_trends = ClickhouseFunnelTrends(filter, self.team,
                                               ClickhouseFunnel)
        results = funnel_trends.perform_query()

        self.assertEqual(
            results,
            [
                {
                    "reached_to_step_count":
                    0,
                    "is_period_final":
                    True,
                    "conversion_rate":
                    0,
                    "reached_from_step_count":
                    1,
                    "timestamp":
                    datetime(2021, 6, 7, 0, 0).replace(tzinfo=pytz.UTC),
                },
                {
                    "reached_to_step_count":
                    0,
                    "is_period_final":
                    True,
                    "conversion_rate":
                    0,
                    "reached_from_step_count":
                    0,
                    "timestamp":
                    datetime(2021, 6, 8, 0, 0).replace(tzinfo=pytz.UTC),
                },
                {
                    "reached_to_step_count":
                    0,
                    "is_period_final":
                    True,
                    "conversion_rate":
                    0,
                    "reached_from_step_count":
                    0,
                    "timestamp":
                    datetime(2021, 6, 9, 0, 0).replace(tzinfo=pytz.UTC),
                },
                {
                    "reached_to_step_count":
                    0,
                    "is_period_final":
                    True,
                    "conversion_rate":
                    0,
                    "reached_from_step_count":
                    0,
                    "timestamp":
                    datetime(2021, 6, 10, 0, 0).replace(tzinfo=pytz.UTC),
                },
                {
                    "reached_to_step_count":
                    0,
                    "is_period_final":
                    True,
                    "conversion_rate":
                    0,
                    "reached_from_step_count":
                    0,
                    "timestamp":
                    datetime(2021, 6, 11, 0, 0).replace(tzinfo=pytz.UTC),
                },
                {
                    "reached_to_step_count":
                    0,
                    "is_period_final":
                    True,
                    "conversion_rate":
                    0,
                    "reached_from_step_count":
                    0,
                    "timestamp":
                    datetime(2021, 6, 12, 0, 0).replace(tzinfo=pytz.UTC),
                },
                {
                    "reached_to_step_count":
                    0,
                    "is_period_final":
                    True,
                    "conversion_rate":
                    0,
                    "reached_from_step_count":
                    0,
                    "timestamp":
                    datetime(2021, 6, 13, 0, 0).replace(tzinfo=pytz.UTC),
                },
            ],
        )