Skip to content

: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.

fix(warehouse-suggestions): read last_read_at as an aware datetime (#119894)

Thiago Salvatore517d40cce09e
diff --git a/products/warehouse_suggestions/backend/logic/reads.py b/products/warehouse_suggestions/backend/logic/reads.py
index 92ca275bca3a..e4de3b37b0b2 100644
--- a/products/warehouse_suggestions/backend/logic/reads.py
+++ b/products/warehouse_suggestions/backend/logic/reads.py
@@ -212,7 +212,7 @@ SELECT
sumIf(read_count, read_alone),
quantilesMergeIf(0.5, 0.9)(duration_ms_quantiles, read_alone)[{FIRST_QUANTILE}],
quantilesMergeIf(0.5, 0.9)(read_bytes_quantiles, read_alone)[{FIRST_QUANTILE}],
- max(max_event_time)
+ toTimeZone(max(max_event_time), 'UTC')
FROM (
SELECT *, {{human}} AS is_human
FROM {WAREHOUSE_OBJECT_READS_DAILY_TABLE}
diff --git a/products/warehouse_suggestions/backend/tests/test_reads.py b/products/warehouse_suggestions/backend/tests/test_reads.py
index 121470d533bd..fcda7847537b 100644
--- a/products/warehouse_suggestions/backend/tests/test_reads.py
+++ b/products/warehouse_suggestions/backend/tests/test_reads.py
@@ -1,5 +1,5 @@
from collections.abc import Mapping
-from datetime import date, timedelta
+from datetime import UTC, date, datetime, time, timedelta
from uuid import UUID, uuid4
from posthog.test.base import BaseTest, ClickhouseTestMixin
@@ -101,6 +101,7 @@ class TestReadTeamReads(ClickhouseTestMixin, BaseTest):
assert (view_reads.human_requests, view_reads.human_users, view_reads.human_days) == (2, 2, 2)
assert (view_reads.human_reads, view_reads.human_duration_ms, view_reads.alone_reads) == (3, 1300, 2)
assert 100 <= view_reads.alone_duration_ms_median <= 300
+ assert view_reads.last_read_at == datetime.combine(YESTERDAY, time(hour=12), tzinfo=UTC)
def _classification(subjects: Mapping[Subject, SubjectReads], subject_id: UUID) -> tuple[bool, Surface | None]: