Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(retention): move weekly active users interval by a day #17342

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@
GROUP BY timestamp, person_id,
breakdown_value) e
WHERE e.timestamp <= d.timestamp
AND e.timestamp > d.timestamp - INTERVAL 6 DAY
AND e.timestamp > d.timestamp - INTERVAL 7 DAY
GROUP BY d.timestamp,
breakdown_value
ORDER BY d.timestamp)
Expand Down
2 changes: 1 addition & 1 deletion posthog/queries/trends/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
{aggregator} AS actor_id
{event_query_base}
GROUP BY timestamp, actor_id
) e WHERE e.timestamp <= d.timestamp + INTERVAL 1 DAY AND e.timestamp > d.timestamp - INTERVAL {prev_interval}
) e WHERE e.timestamp <= d.timestamp AND e.timestamp > d.timestamp - INTERVAL {prev_interval}
GROUP BY d.timestamp
ORDER BY d.timestamp
) WHERE 1 = 1 {parsed_date_from} {parsed_date_to}
Expand Down
2 changes: 1 addition & 1 deletion posthog/queries/trends/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def get_active_user_params(filter: Filter, entity: Entity, team_id: int) -> Tupl
date_to = filter.date_to

format_params = {
"prev_interval": "6 DAY" if entity.math == WEEKLY_ACTIVE else "29 DAY",
"prev_interval": "7 DAY" if entity.math == WEEKLY_ACTIVE else "30 DAY",
"parsed_date_from_prev_range": f"AND toDateTime(timestamp, 'UTC') >= toDateTime(%(date_from_active_users_adjusted)s, %(timezone)s)",
}

Expand Down