-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(assistant): increase properties sample count (#27967)
- Loading branch information
Showing
10 changed files
with
127 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,28 +124,28 @@ def test_retrieve_entity_property_values(self): | |
team=self.team, type=PropertyDefinition.Type.PERSON, name="id", property_type=PropertyType.Numeric | ||
) | ||
|
||
for i in range(5): | ||
for i in range(25): | ||
id = f"person{i}" | ||
with freeze_time(f"2024-01-01T{i}:00:00Z"): | ||
with freeze_time(f"2024-01-01T00:{i}:00Z"): | ||
_create_person( | ||
distinct_ids=[id], | ||
properties={"email": f"{id}@example.com", "id": i}, | ||
team=self.team, | ||
) | ||
with freeze_time(f"2024-01-02T00:00:00Z"): | ||
_create_person( | ||
distinct_ids=["person5"], | ||
properties={"email": "person5@example.com", "id": 5}, | ||
distinct_ids=["person25"], | ||
properties={"email": "person25@example.com", "id": 25}, | ||
team=self.team, | ||
) | ||
|
||
self.assertEqual( | ||
self.assertIn( | ||
'"[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]"', | ||
toolkit.retrieve_entity_property_values("person", "email"), | ||
'"[email protected]", "[email protected]", "[email protected]", "[email protected]", "[email protected]" and 1 more distinct value.', | ||
) | ||
self.assertEqual( | ||
self.assertIn( | ||
"1 more distinct value", | ||
toolkit.retrieve_entity_property_values("person", "id"), | ||
"5, 4, 3, 2, 1 and 1 more distinct value.", | ||
) | ||
|
||
toolkit = DummyToolkit(self.team) | ||
|
@@ -181,7 +181,7 @@ def test_retrieve_entity_property_values(self): | |
|
||
self.assertEqual( | ||
toolkit.retrieve_entity_property_values("proj", "test"), | ||
"6, 5, 4, 3, 2 and 2 more distinct values.", | ||
"6, 5, 4, 3, 2, 1, 0", | ||
) | ||
self.assertEqual(toolkit.retrieve_entity_property_values("org", "test"), '"7"') | ||
|
||
|
@@ -257,7 +257,7 @@ def test_retrieve_event_property_values(self): | |
self.assertEqual(toolkit.retrieve_event_property_values("event1", "bool"), "true") | ||
self.assertEqual( | ||
toolkit.retrieve_event_property_values("event1", "id"), | ||
"9, 8, 7, 6, 5 and 5 more distinct values.", | ||
"9, 8, 7, 6, 5, 4, 3, 2, 1, 0", | ||
) | ||
self.assertEqual( | ||
toolkit.retrieve_event_property_values("event1", "date"), f'"{datetime(2024, 1, 1).isoformat()}"' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -411,3 +411,36 @@ def test_property_taxonomy_includes_events_with_partial_property_matches(self): | |
self.assertEqual(response.results[1].property, "$host") | ||
self.assertEqual(response.results[1].sample_values, ["us.posthog.com"]) | ||
self.assertEqual(response.results[1].sample_count, 1) | ||
|
||
def test_query_count(self): | ||
_create_person( | ||
distinct_ids=["person1"], | ||
properties={"email": "[email protected]"}, | ||
team=self.team, | ||
) | ||
_create_event( | ||
event="event1", | ||
distinct_id="person1", | ||
properties={"prop": "1"}, | ||
team=self.team, | ||
) | ||
_create_event( | ||
event="event1", | ||
distinct_id="person2", | ||
properties={"prop": "2"}, | ||
team=self.team, | ||
) | ||
_create_event( | ||
event="event1", | ||
distinct_id="person2", | ||
properties={"prop": "3"}, | ||
team=self.team, | ||
) | ||
|
||
response = EventTaxonomyQueryRunner( | ||
team=self.team, query=EventTaxonomyQuery(event="event1", properties=["prop"], maxPropertyValues=1) | ||
).calculate() | ||
self.assertEqual(len(response.results), 1) | ||
self.assertEqual(response.results[0].property, "prop") | ||
self.assertEqual(response.results[0].sample_count, 3) | ||
self.assertEqual(len(response.results[0].sample_values), 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters