:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(endpoints): include read_from in the materialized compare range (#126104)
Thomas Obermüller5f22f852790f
diff --git a/products/endpoints/backend/insight_transformers.py b/products/endpoints/backend/insight_transformers.pyindex 37ecffd2494b..42df91e50724 100644--- a/products/endpoints/backend/insight_transformers.py+++ b/products/endpoints/backend/insight_transformers.py@@ -14,7 +14,7 @@ from zoneinfo import ZoneInfoimport structlog-from posthog.schema import HogQLQueryModifiers, HogQLQueryResponse+from posthog.schema import HogQLQueryModifiers, HogQLQueryResponse, ResolvedDateRangeResponsefrom posthog.hogql_queries.query_runner import get_query_runnerfrom posthog.models.team import Team@@ -192,10 +192,10 @@ def _transform_trends(result: dict, original_query: dict, team: Team, now: datetrows = result.get("results", [])if runner.query.compareFilter is not None and runner.query.compareFilter.compare:- result["resolved_compare_date_range"] = {- "date_from": runner.query_previous_date_range.date_from(),- "date_to": runner.query_previous_date_range.date_to(),- }+ result["resolved_compare_date_range"] = ResolvedDateRangeResponse(+ date_from=runner.query_previous_date_range.date_from(),+ date_to=runner.query_previous_date_range.date_to(),+ ).model_dump()if not rows:result["results"] = []diff --git a/products/endpoints/backend/tests/test_insight_response_parity.py b/products/endpoints/backend/tests/test_insight_response_parity.pyindex 05e7e3113bc1..9e53b84d0d71 100644--- a/products/endpoints/backend/tests/test_insight_response_parity.py+++ b/products/endpoints/backend/tests/test_insight_response_parity.py@@ -374,6 +374,7 @@ class TestInsightResponseParity(ClickhouseTestMixin, APIBaseTest):assert result["resolved_compare_date_range"] == {"date_from": datetime(2026, 9, 12, tzinfo=UTC),"date_to": datetime(2026, 9, 19, 23, 59, 59, 999999, tzinfo=UTC),+ "read_from": None,}# =========================================================================diff --git a/products/product_analytics/backend/tests/api/test_insight.py b/products/product_analytics/backend/tests/api/test_insight.pyindex 640007fbdd42..ff14d59e2163 100644--- a/products/product_analytics/backend/tests/api/test_insight.py+++ b/products/product_analytics/backend/tests/api/test_insight.py@@ -3329,7 +3329,7 @@ class TestInsight(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):self.assertIsNotNone(response["results"][0]["hogql"])self.assertEqual(response["results"][0]["resolved_compare_date_range"],- {"date_from": "2012-01-01T00:00:00Z", "date_to": "2012-01-08T23:59:59.999999Z"},+ {"date_from": "2012-01-01T00:00:00Z", "date_to": "2012-01-08T23:59:59.999999Z", "read_from": None},)def test_insight_returns_cached_types(self) -> None: