refactor(metrics): split the histogram runner calculation into named phases - #111229
posthog[bot] wants to merge 1 commit into
Conversation
…phases Move interval selection, runner construction, query execution, bounds validation, time grid construction and count assembly out of MetricsHistogramQueryRunner._calculate into private methods. _calculate keeps the orchestration and the cell limit check. Query and response behavior do not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Generated-By: PostHog Desktop Task-Id: 62e1a066-0f20-49eb-b6ca-62a29713feee
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
🤖 CI report
|
| File | Comment lines | Added lines |
|---|---|---|
products/metrics/backend/hogql_queries/metrics_histogram_query_runner.py |
9 | 59 |
This check does not block merging. It updates on every push and clears when the share drops.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (7)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe histogram query runner now delegates interval selection, runner construction, histogram execution, shared-bound validation, grid-time generation, cell-limit enforcement, and count assembly to dedicated methods. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No actionable issue is identified that would prevent merging after normal checks. 🚥 Pre-merge checks | ❌ 1❌ Failed checks (1 warning)
Full details: Description checkExplanation The Problem, Changes, testing, release status, notifications, and docs sections are present and specific. However, the agent context omits required definition-of-done details, including patch-coverage evidence, the public-artifact statement, and the CodeRabbit CLI result or reason for skipping it. Resolution Complete the agent context with the patch-coverage result or justification, a public-artifact statement, and the CodeRabbit CLI findings and disposition or the applicable reason it was skipped. State whether the new-events-schema gate applies and, if it does, provide its result.
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
HostHog preview —
|
Problem
MetricsHistogramQueryRunner._calculatescores C901 14, above the repository limit of 10.Origin
Changes
_calculatenow only orchestrates the phases. Each phase is a named private method:_resolve_interval,_build_runner,_execute_histogram_query,_shared_bounds,_grid_times,_grid_counts._calculate, between grid construction and count assembly, as before._calculatenow scores below the C901 limit of 10.How did you test this code?
hogli test products/metrics/backend/tests/test_metrics_histogram_query_runner.pyagainst the local dev stack. All 10 existing cases pass. They cover empty data, invalid ranges, metric type filters, grid boundaries, the cell limit, mixed bounds, weekly buckets and API scopes.ruff check,ruff formatand a C901 check with a limit of 10 on the changed file.uv run mypy --cache-fine-grained .with no issues.Test rationale: No new test. The change preserves behavior, and the existing focused suite covers each extracted phase.
Release status
Automatic notifications
Docs update
None. Internal refactor.
🤖 Agent context
Autonomy: Fully autonomous
Agent: PostHog Desktop (Claude Code), claude-opus-5-5
/writing-pr-descriptions.Created with PostHog Desktop from this inbox report.
🤖 Generated with Claude Code