Repository navigation
refactor: Decompose heatmap query and view builders - #3276
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
| export type HeatmapQuery = { | ||
| mode: 'distribution'; |
There was a problem hiding this comment.
This type will gain a second mode (series in subsequent PRs)
There was a problem hiding this comment.
Sounds good. Might be good to establish an ENUM at that time to avoid repeating plain text.
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
| @@ -81,7 +78,7 @@ export function useHeatmapData({ | |||
| queryKey: ['heatmap_bucket', bucketConfig], | |||
| // Wait for fresh bounds, so a refresh doesn't also query the new range | |||
| // bucketed with the previous range's min/max. | |||
| enabled: canQueryBuckets && !isMinMaxPlaceholderData, | |||
| enabled: enabled && canQueryBuckets && !isMinMaxPlaceholderData, | |||
There was a problem hiding this comment.
🔵 minor — The bucket query now waits on enabled, which changes behaviour and has no test
The PR says nothing should behave differently, but the bucket query now also checks enabled, so a disabled chart (e.g. DBSearchHeatmapChart with isReady=false) no longer fetches buckets from cached bounds. Mention this in the PR description and add a render test where enabled={false} with settled bounds expects lastOptionsFor('heatmap_bucket')?.enabled to be false. Every current test uses the default enabled=true, so removing the new check would still pass.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| import { NumberFormat } from '@/types'; | ||
| import { formatDurationMsCompact, formatNumber } from '@/utils'; | ||
|
|
||
| import type { HeatmapScaleType } from './heatmapGrid'; | ||
|
|
||
| /** Number format for a heatmap of trace durations in ms. */ | ||
| export const HEATMAP_DURATION_NUMBER_FORMAT = { |
There was a problem hiding this comment.
🔵 minor — HEATMAP_DURATION_NUMBER_FORMAT duplicates the literal in EditTimeChartForm
applyHeatmapDefaults in packages/app/src/components/DBEditTimeChartForm/EditTimeChartForm.tsx:174 still hardcodes { output: 'duration', factor: 0.001 } for the same heatmap duration default. Import the new constant there (spread it if setValue needs a mutable object) so the two can't drift apart.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
| [fromMs, toMs, granularity], | ||
| ); | ||
|
|
||
| return { granularity, generatedTsBuckets, fromMs, toMs }; |
There was a problem hiding this comment.
🔵 minor — useHeatmapTimeBuckets returns fromMs/toMs, but nothing reads them
The only caller (useHeatmapData.ts:38) destructures just granularity and generatedTsBuckets. Return only those two values.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
PR Review
3 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 3 minor 1 posted as inline comment(s) on the changed lines. 1 listed below. 1 unchanged from an earlier push (already inline above). Findings outside the changed lines1 minor
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
6f9158c to
2b3a0eb
Compare
E2E Test Results✅ All tests passed • 393 passed • 1 skipped • 1618s
Tests ran across 4 shards in parallel. |
| darkPalette: ['#000'], | ||
| lightPalette: ['#fff'], | ||
| toHeatmapChartConfig: jest.fn(() => ({ heatmapConfig: {} })), | ||
| toHeatmapQuery: jest.fn(() => ({ |
There was a problem hiding this comment.
🔵 minor — No test checks that the scale chosen in Search reaches the heatmap
DBSearchHeatmapChart used to pass scaleType as a prop. Now the scale only arrives through select[0].heatmapScaleType inside toHeatmapQuery. The mock always returns scaleType: 'log' and nothing asserts on its arguments, so if heatmapScaleType were dropped and linear mode silently fell back to log, the test would still pass. Add an assertion that toHeatmapQuery receives select[0].heatmapScaleType === 'linear' when the setting is linear, or run the real toHeatmapQuery and assert on query.scaleType.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
|
Deep Review✅ No critical issues found. This is a clean, behavior-preserving decomposition: the 🔵 P3 nitpicks (2)
Reviewers (4): correctness (orchestrator-verified), api-contract (orchestrator-verified), previous-comments, agent-native. Testing gaps: The extracted No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
Summary
This PR applies a few refactors to heatmap related components, hooks, and utilities. This is motivated by a new heatmap "mode" which will build, query, and plot a different data shape.
No behavior changes are expected in this PR.
Screenshots or video
How to test on Vercel preview
View the heatmap in search event deltas, in a dashboard, or in chart explorer.
References