From 42ea56d0dfb3d61f0d1029edf464495e0107b4f6 Mon Sep 17 00:00:00 2001 From: Georgiy Tarasov Date: Wed, 15 Jan 2025 10:00:51 +0100 Subject: [PATCH] fix: set snapshot dates --- .../ai/test/__snapshots__/test_traces_query_runner.ambr | 8 ++++---- posthog/hogql_queries/ai/test/test_traces_query_runner.py | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/posthog/hogql_queries/ai/test/__snapshots__/test_traces_query_runner.ambr b/posthog/hogql_queries/ai/test/__snapshots__/test_traces_query_runner.ambr index 72156bc23bfdc..c5931f8c340fd 100644 --- a/posthog/hogql_queries/ai/test/__snapshots__/test_traces_query_runner.ambr +++ b/posthog/hogql_queries/ai/test/__snapshots__/test_traces_query_runner.ambr @@ -74,7 +74,7 @@ WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id) - WHERE and(equals(events.team_id, 99999), equals(events.event, '$ai_generation'), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-06 23:50:00', 6, 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-14 20:58:59', 6, 'UTC')))) + WHERE and(equals(events.team_id, 99999), equals(events.event, '$ai_generation'), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-08 23:50:00', 6, 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-16 00:10:59', 6, 'UTC')))) GROUP BY id ORDER BY trace_timestamp DESC LIMIT 5 @@ -118,7 +118,7 @@ WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id) - WHERE and(equals(events.team_id, 99999), equals(events.event, '$ai_generation'), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-06 23:50:00', 6, 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-14 20:58:59', 6, 'UTC')))) + WHERE and(equals(events.team_id, 99999), equals(events.event, '$ai_generation'), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-08 23:50:00', 6, 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-16 00:10:59', 6, 'UTC')))) GROUP BY id ORDER BY trace_timestamp DESC LIMIT 5 @@ -162,7 +162,7 @@ WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id) - WHERE and(equals(events.team_id, 99999), equals(events.event, '$ai_generation'), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-06 23:50:00', 6, 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-14 20:58:59', 6, 'UTC')))) + WHERE and(equals(events.team_id, 99999), equals(events.event, '$ai_generation'), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-08 23:50:00', 6, 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-16 00:10:59', 6, 'UTC')))) GROUP BY id ORDER BY trace_timestamp DESC LIMIT 5 @@ -206,7 +206,7 @@ WHERE equals(person.team_id, 99999) GROUP BY person.id HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS events__person ON equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), events__person.id) - WHERE and(equals(events.team_id, 99999), equals(events.event, '$ai_generation'), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-06 23:50:00', 6, 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-14 20:58:59', 6, 'UTC'))), ifNull(equals(id, 'trace1'), 0)) + WHERE and(equals(events.team_id, 99999), equals(events.event, '$ai_generation'), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-08 23:50:00', 6, 'UTC'))), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2025-01-16 00:10:59', 6, 'UTC'))), ifNull(equals(id, 'trace1'), 0)) GROUP BY id ORDER BY trace_timestamp DESC LIMIT 101 diff --git a/posthog/hogql_queries/ai/test/test_traces_query_runner.py b/posthog/hogql_queries/ai/test/test_traces_query_runner.py index 6a03217e85529..5956ffefc8441 100644 --- a/posthog/hogql_queries/ai/test/test_traces_query_runner.py +++ b/posthog/hogql_queries/ai/test/test_traces_query_runner.py @@ -241,6 +241,7 @@ def test_field_mapping(self): }, ) + @freeze_time("2025-01-16T00:00:00Z") @snapshot_clickhouse_queries def test_trace_id_filter(self): _create_person(distinct_ids=["person1"], team=self.team) @@ -252,6 +253,7 @@ def test_trace_id_filter(self): self.assertEqual(len(response.results), 1) self.assertEqual(response.results[0].id, "trace1") + @freeze_time("2025-01-16T00:00:00Z") @snapshot_clickhouse_queries def test_pagination(self): _create_person(distinct_ids=["person1"], team=self.team) @@ -261,8 +263,8 @@ def test_pagination(self): distinct_id="person1" if i % 2 == 0 else "person2", team=self.team, trace_id=f"trace_{i}", + timestamp=datetime(2025, 1, 15, i), ) - response = TracesQueryRunner(team=self.team, query=TracesQuery(limit=4, offset=0)).calculate() self.assertEqual(response.hasMore, True) self.assertEqual(len(response.results), 5) @@ -286,6 +288,7 @@ def test_pagination(self): self.assertEqual(len(response.results), 1) self.assertEqual(response.results[0].id, "trace_0") + @freeze_time("2025-01-16T00:00:00Z") def test_maps_all_fields(self): _create_person(distinct_ids=["person1"], team=self.team) _create_ai_generation_event(