diff --git a/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr b/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr index 97bfe2fae2e91..a819a129b7bed 100644 --- a/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr +++ b/posthog/hogql_queries/insights/trends/test/__snapshots__/test_trends.ambr @@ -1560,7 +1560,7 @@ WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 13:01:01', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), and(equals(e.event, 'sign up'), ifNull(in(e__pdi.person_id, (SELECT cohortpeople.person_id FROM cohortpeople - WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 35)) + WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 37)) GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0))), 0))) GROUP BY value @@ -1607,7 +1607,7 @@ WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 13:01:01', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), and(equals(e.event, 'sign up'), ifNull(in(e__pdi.person_id, (SELECT cohortpeople.person_id FROM cohortpeople - WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 35)) + WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 37)) GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0))), 0)), or(isNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'other_value'), 0))) GROUP BY day_start, @@ -1652,7 +1652,7 @@ WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 13:01:01', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), and(equals(e.event, 'sign up'), in(e.person_id, (SELECT cohortpeople.person_id FROM cohortpeople - WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 36)) + WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 38)) GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0))))) GROUP BY value @@ -1692,7 +1692,7 @@ WHERE and(equals(e.team_id, 2), greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toStartOfDay(assumeNotNull(parseDateTime64BestEffortOrNull('2019-12-28 13:01:01', 6, 'UTC')))), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-04 23:59:59', 6, 'UTC'))), and(equals(e.event, 'sign up'), in(e.person_id, (SELECT cohortpeople.person_id FROM cohortpeople - WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 36)) + WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 38)) GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0)))), or(isNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', '')), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'value'), 0), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(e.properties, '$some_property'), ''), 'null'), '^"|"$', ''), 'other_value'), 0))) GROUP BY day_start, diff --git a/posthog/hogql_queries/insights/trends/test/test_trends.py b/posthog/hogql_queries/insights/trends/test/test_trends.py index dcf71a3b7d2ca..45155a38b1e53 100644 --- a/posthog/hogql_queries/insights/trends/test/test_trends.py +++ b/posthog/hogql_queries/insights/trends/test/test_trends.py @@ -176,10 +176,6 @@ def convert_filter_to_trends_query(filter: Filter) -> TrendsQuery: kind="TrendsQuery", filterTestAccounts=filter.filter_test_accounts, dateRange=DateRange(date_from=filter_as_dict.get("date_from"), date_to=filter_as_dict.get("date_to")), - # dateRange=DateRange( - # date_from=filter.date_from.isoformat() if filter.date_from is not None else "all", - # date_to=filter.date_to.isoformat() if filter.date_to is not None else None, - # ), samplingFactor=filter.sampling_factor, aggregation_group_type_index=filter.aggregation_group_type_index, breakdown=BreakdownFilter( @@ -4423,34 +4419,33 @@ def test_breakdown_by_person_property_pie_with_event_dau_filter(self): self.assertDictContainsSubset({"breakdown_value": "person1", "aggregated_value": 1}, event_response[0]) self.assertDictContainsSubset({"breakdown_value": "person2", "aggregated_value": 1}, event_response[1]) - # TODO: test_account_filters conversion - # @also_test_with_materialized_columns(person_properties=["name"]) - # def test_filter_test_accounts_cohorts(self): - # self._create_person(team_id=self.team.pk, distinct_ids=["person_1"], properties={"name": "John"}) - # self._create_person(team_id=self.team.pk, distinct_ids=["person_2"], properties={"name": "Jane"}) + @also_test_with_materialized_columns(person_properties=["name"]) + def test_filter_test_accounts_cohorts(self): + self._create_person(team_id=self.team.pk, distinct_ids=["person_1"], properties={"name": "John"}) + self._create_person(team_id=self.team.pk, distinct_ids=["person_2"], properties={"name": "Jane"}) - # self._create_event(event="event_name", team=self.team, distinct_id="person_1") - # self._create_event(event="event_name", team=self.team, distinct_id="person_2") - # self._create_event(event="event_name", team=self.team, distinct_id="person_2") + self._create_event(event="event_name", team=self.team, distinct_id="person_1") + self._create_event(event="event_name", team=self.team, distinct_id="person_2") + self._create_event(event="event_name", team=self.team, distinct_id="person_2") - # cohort = _create_cohort( - # team=self.team, - # name="cohort1", - # groups=[{"properties": [{"key": "name", "value": "Jane", "type": "person"}]}], - # ) - # self.team.test_account_filters = [{"key": "id", "value": cohort.pk, "type": "cohort"}] - # self.team.save() + cohort = _create_cohort( + team=self.team, + name="cohort1", + groups=[{"properties": [{"key": "name", "value": "Jane", "type": "person"}]}], + ) + self.team.test_account_filters = [{"key": "id", "value": cohort.pk, "type": "cohort"}] + self.team.save() - # response = self._run( - # Filter( - # data={"events": [{"id": "event_name"}], "filter_test_accounts": True}, - # team=self.team, - # ), - # self.team, - # ) + response = self._run( + Filter( + data={"events": [{"id": "event_name"}], "filter_test_accounts": True}, + team=self.team, + ), + self.team, + ) - # self.assertEqual(response[0]["count"], 2) - # self.assertEqual(response[0]["data"][-1], 2) + self.assertEqual(response[0]["count"], 2) + self.assertEqual(response[0]["data"][-1], 2) def test_filter_by_precalculated_cohort(self): self._create_person(team_id=self.team.pk, distinct_ids=["person_1"], properties={"name": "John"})