Skip to content

Commit

Permalink
fix: date_to must be less than daily interval
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Dec 4, 2024
1 parent 8b483e2 commit 8eb830c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
EventPropertyFilter,
GroupPropertyFilter,
HogQLPropertyFilter,
IntervalType,
)
from posthog.session_recordings.queries.session_replay_events import ttl_days

Expand Down Expand Up @@ -249,7 +250,8 @@ def query_date_range(self):
return QueryDateRange(
date_range=DateRange(date_from=self._query.date_from, date_to=self._query.date_to),
team=self._team,
interval=None,
# we don't want the ranger to ceiling to the end of the day for date_to
interval=IntervalType.MINUTE,
now=datetime.now(),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3854,7 +3854,7 @@
ifNull(greaterOrEquals(max(toTimeZone(s._timestamp, 'UTC')), toDateTime64('2023-08-30 11:55:01.000000', 6, 'UTC')), 0) AS ongoing,
round(multiply(divide(plus(plus(plus(divide(sum(s.active_milliseconds), 1000), sum(s.click_count)), sum(s.keypress_count)), sum(s.console_error_count)), plus(plus(plus(plus(sum(s.mouse_activity_count), dateDiff('SECOND', start_time, end_time)), sum(s.console_error_count)), sum(s.console_log_count)), sum(s.console_warn_count))), 100), 2) AS activity_score
FROM session_replay_events AS s
WHERE and(equals(s.team_id, 99999), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2023-08-09 12:00:01.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2023-08-27 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2023-08-30 23:59:59.999999', 6, 'UTC')), 0))
WHERE and(equals(s.team_id, 99999), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2023-08-09 12:00:01.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2023-08-27 12:00:01.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2023-08-30 12:00:59.999999', 6, 'UTC')), 0))
GROUP BY s.session_id
HAVING 1
ORDER BY start_time DESC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,9 @@ def test_listing_ignores_future_replays(self):
with freeze_time("2023-08-29T12:00:01Z"):
produce_replay_summary(team_id=self.team.id, session_id="29th Aug")

with freeze_time("2023-08-30T14:00:01Z"):
produce_replay_summary(team_id=self.team.id, session_id="30th Aug 1400")

with freeze_time("2023-09-01T12:00:01Z"):
produce_replay_summary(team_id=self.team.id, session_id="1st-sep")

Expand All @@ -787,6 +790,7 @@ def test_listing_ignores_future_replays(self):
with freeze_time("2023-09-03T12:00:01Z"):
produce_replay_summary(team_id=self.team.id, session_id="3rd-sep")

# before the recording on the thirtieth so should exclude it
with freeze_time("2023-08-30T12:00:01Z"):
recordings = self._filter_recordings_by()

Expand Down

0 comments on commit 8eb830c

Please sign in to comment.