fix(query-view): default time range to a relative window anchored at now - #298
Draft
haileyok wants to merge 2 commits into
Draft
fix(query-view): default time range to a relative window anchored at now#298haileyok wants to merge 2 commits into
haileyok wants to merge 2 commits into
Conversation
When loading the query view, derive start/end from the relative
interval ("Last Day", "Last Hour", etc.) at extraction time instead of
honoring whatever literal timestamps were on the URL. Custom intervals
still preserve the explicit timestamps the user picked.
Two failure modes shared this root cause:
- Fresh page load (no URL params) silently rendered empty graphs and
event stream because start/end were "" and Timeseries/EventStream
short-circuit on empty range; users had to click Submit before
seeing anything.
- Reloading a bookmarked URL with `interval=day` and stale start/end
queried the historical 24h window from the previous session, so
recent data fell outside the range.
Both flows now produce a "now - <interval>" to "now" range on every
extraction. saveQueryToHistory still only fires when the URL had
explicit start/end so a fresh page load does not record a query
history entry.
Refs #96
If a URL had an unrecognized `interval=...` value, the new recompute path would call into getQueryDateRange and throw on the missing IntervalOptions entry. Skip the recompute when the interval isn't a known key, falling through to the URL timestamps so a malformed link behaves the same way it did before this fix.
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
| // the user picked from the date-range picker. | ||
| let start = startParam; | ||
| let end = endParam; | ||
| if (interval != null && interval !== CUSTOM_RANGE_OPTION && interval in IntervalOptions) { |
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.
Description
Fixes the issue from the friction log #96 (sub-item 4) where the query view shows no data by default.
Root cause
Two failure modes shared one root cause: the URL stored
start/endas frozen literal timestamps whileinterval(when notcustom) carried the semantic intent of "relative to now".extractQueryStateFromSearchParamsin `osprey_ui/src/utils/QueryStoreUtils.tsx` never derived start/end from the relative interval at extraction time.Both theories from the dispatch were correct:
Fix
In `extractQueryStateFromSearchParams`:
The defensive `interval in IntervalOptions` check guards against a URL with an unrecognized `interval=` value (which would otherwise blow up in `getQueryDateRange`'s destructuring).
Tests
Added `osprey_ui/src/utils/QueryStoreUtils.test.tsx` covering:
Out of scope
Closes #96 will be set once the operator confirms; for now this is sub-item 4 of the friction log, so refs #96.
Checklist