|
| 1 | +import unittest |
1 | 2 | from uuid import uuid4
|
2 | 3 |
|
3 | 4 | from ee.clickhouse.models.event import create_event
|
@@ -78,6 +79,62 @@ def test_auto_bin_count_single_step(self):
|
78 | 79 | },
|
79 | 80 | )
|
80 | 81 |
|
| 82 | + @unittest.skip("Wait for bug to be resolved") |
| 83 | + def test_auto_bin_count_single_step_duplicate_events(self): |
| 84 | + # demonstrates existing CH bug. Current patch is to remove negative times from consideration |
| 85 | + # Reference on what happens: https://github.com/ClickHouse/ClickHouse/issues/26580 |
| 86 | + |
| 87 | + _create_person(distinct_ids=["user a"], team=self.team) |
| 88 | + _create_person(distinct_ids=["user b"], team=self.team) |
| 89 | + _create_person(distinct_ids=["user c"], team=self.team) |
| 90 | + |
| 91 | + _create_event(event="step one", distinct_id="user a", team=self.team, timestamp="2021-06-08 18:00:00") |
| 92 | + _create_event(event="step one", distinct_id="user a", team=self.team, timestamp="2021-06-08 19:00:00") |
| 93 | + # Converted from 0 to 1 in 3600 s |
| 94 | + _create_event(event="step one", distinct_id="user a", team=self.team, timestamp="2021-06-08 21:00:00") |
| 95 | + |
| 96 | + _create_event(event="step one", distinct_id="user b", team=self.team, timestamp="2021-06-09 13:00:00") |
| 97 | + _create_event(event="step one", distinct_id="user b", team=self.team, timestamp="2021-06-09 13:37:00") |
| 98 | + # Converted from 0 to 1 in 2200 s |
| 99 | + |
| 100 | + _create_event(event="step one", distinct_id="user c", team=self.team, timestamp="2021-06-11 07:00:00") |
| 101 | + _create_event(event="step one", distinct_id="user c", team=self.team, timestamp="2021-06-12 06:00:00") |
| 102 | + # Converted from 0 to 1 in 82_800 s |
| 103 | + |
| 104 | + filter = Filter( |
| 105 | + data={ |
| 106 | + "insight": INSIGHT_FUNNELS, |
| 107 | + "interval": "day", |
| 108 | + "date_from": "2021-06-07 00:00:00", |
| 109 | + "date_to": "2021-06-13 23:59:59", |
| 110 | + "funnel_from_step": 0, |
| 111 | + "funnel_to_step": 1, |
| 112 | + "funnel_window_days": 7, |
| 113 | + "events": [ |
| 114 | + {"id": "step one", "order": 0}, |
| 115 | + {"id": "step one", "order": 1}, |
| 116 | + {"id": "step one", "order": 2}, |
| 117 | + ], |
| 118 | + } |
| 119 | + ) |
| 120 | + |
| 121 | + funnel_trends = ClickhouseFunnelTimeToConvert(filter, self.team, ClickhouseFunnel) |
| 122 | + results = funnel_trends.run() |
| 123 | + |
| 124 | + # Autobinned using the minimum time to convert, maximum time to convert, and sample count |
| 125 | + self.assertEqual( |
| 126 | + results, |
| 127 | + { |
| 128 | + "bins": [ |
| 129 | + (2220.0, 2), # Reached step 1 from step 0 in at least 2200 s but less than 29_080 s - users A and B |
| 130 | + (29080.0, 0), # Analogous to above, just an interval (in this case 26_880 s) up - no users |
| 131 | + (55940.0, 0), # Same as above |
| 132 | + (82800.0, 1), # Reached step 1 from step 0 in at least 82_800 s but less than 109_680 s - user C |
| 133 | + ], |
| 134 | + "average_conversion_time": 29_540, |
| 135 | + }, |
| 136 | + ) |
| 137 | + |
81 | 138 | def test_custom_bin_count_single_step(self):
|
82 | 139 | _create_person(distinct_ids=["user a"], team=self.team)
|
83 | 140 | _create_person(distinct_ids=["user b"], team=self.team)
|
|
0 commit comments