chore(trends): add hide weekend data bucket-alignment regression tests - #15
Open
lordspline wants to merge 1 commit into
Open
chore(trends): add hide weekend data bucket-alignment regression tests#15lordspline wants to merge 1 commit into
lordspline wants to merge 1 commit into
Conversation
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Lock in the corrected behavior for issue PostHog#61782: with hideWeekends enabled on a daily trends insight, only Saturday/Sunday buckets are dropped and every weekday bucket (and its real value) is preserved, including the in-progress week after the most recent weekend. Covers ranges ending on each weekday, multiple weekends, timezone offsets, a DST boundary, comparison series, a configured Sunday week start, and truly-empty weekday buckets, plus direct alignment checks on _filter_weekend_buckets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Issue #61782 reported that enabling Hide weekend data on a daily Trends insight zeroed out every weekday after the most recent weekend — the in-progress week showed
0even though those days had data with the toggle off.The production fix already landed on
master:_filter_weekend_buckets(posthog/hogql_queries/insights/trends/trends_query_runner.py) builds a parsed-weekday index mask and re-indexesdays/data/labels/counttogether, dropping only Saturday and Sunday while keeping every weekday bucket and its value. The duplicate community PR PostHog#61791 was closed by a maintainer as already fixed.I reproduced the exact issue scenario (a daily range ending Thursday, with a weekend before the final
Mon–Thurun) against currentmasterand it does not reproduce — the in-progress week keeps its real values and onlySat/Sunare removed. This PR does not change production code; it adds the regression coverage that was missing so the corrected alignment can't silently regress.Changes
Tests only — no production behavior change.
Adds regression tests in
posthog/hogql_queries/insights/trends/test/test_trends_query_runner.pythat pin the "hide weekend data" contract end-to-end and at the bucket-alignment layer:0.0(distinguishes a real empty bucket from the bug's zeroing).Sat/Sundrop.US/Pacific).Sat/Sunwith no off-by-one bucket shift._filter_weekend_bucketschecks — parameterized over ranges ending on every weekday, multiple weekends across three weeks, the no-weekend identity case, and cumulative-display count recomputation.How did you test this code?
I'm an agent (Captain Capy). I ran only automated tests — no manual UI testing is claimed.
hogli test posthog/hogql_queries/insights/trends/test/test_trends_query_runner.py -- -k weekend→ 22 passed (16 new + 6 pre-existing).ruff checkandruff format --checkon the changed file → clean. Pre-committytype check passed.master(in-progress week == [3, 3, 3, 12]) and fail against a variant that reproduces the reported zeroing ([0, 0, 0, 0]), confirming the tests actually guard the symptom.Automatic notifications
Docs update
No docs change — behavior is unchanged; this only adds regression tests.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Authored with Capy (Captain Capy). The task asked to fix the issue end-to-end, starting from a deterministic reproduction. Investigation showed current
masteralready contains the fix (re-indexing weekend buckets rather than zeroing in place), and the contributor PR PostHog#61791 was closed as already fixed, so changing production code was explicitly out of scope. The chosen deliverable is the missing parameterized regression suite plus a documented reproduction proving non-recurrence. A naive "replace the zeroes in rendered output" approach was rejected in favor of asserting the bucket re-indexing invariant directly. Agent-authored — requires human review; do not self-merge.