-
Notifications
You must be signed in to change notification settings - Fork 13
fix: update cmr query key to cache bust on start and end date #1928
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: update cmr query key to cache bust on start and end date #1928
Conversation
✅ Deploy Preview for veda-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| : envApiCMREndpoint; | ||
| const statResponse = await queryClient.fetchQuery( | ||
| ['analysis', datasetData.id, 'cmr', aoi], | ||
| ['analysis', datasetData.id, 'cmr', aoi, start, end], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I notice we don't use the formattedParamString in the query key. This leads me to believe it's desired that not all params should cache bust this query. In that case, are there any additional params I should add?
datasetData.timeInterval?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question!
For this dataset, the only parameters that actually vary with user interaction are start, end and the aoi.
datasetData.timeInterval?
timeInterval is a bit different. It’s a fixed prop of the dataset (eg. 'P1M' for monthly data) and comes straight from the config. With the current UI and architecture, users never change it and the backend (I think) doesn’t treat it as a dynamic input. Because of that, we don't have to include it in the key here.
| } | ||
|
|
||
| export async function requestCMRTimeseriesData({ | ||
| async function requestCMRTimeseriesData({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function is not used elsewhere. if functions are exported solely for tests, I suggest we prefix with private_ or _ so we can add a eslint rule to prevent imports of these functions outside of tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the cleanup! I agree with removing the export. We generally rely on module scope (exported vs. non-exported) to signal privacy rather than using naming prefixes like private_.
I think if we ever need to reuse this logic elsewhere, we should extract it into a dedicated util file or custom hook at that point. But for now, keeping it non-exported here is perfect.
dzole0311
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with the Ozone Concentration CMR dataset:
- Analysis runs correctly
- Updating the time range and rerunning now works as expected
Thanks for the fix @ifsimicoded!
| : envApiCMREndpoint; | ||
| const statResponse = await queryClient.fetchQuery( | ||
| ['analysis', datasetData.id, 'cmr', aoi], | ||
| ['analysis', datasetData.id, 'cmr', aoi, start, end], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question!
For this dataset, the only parameters that actually vary with user interaction are start, end and the aoi.
datasetData.timeInterval?
timeInterval is a bit different. It’s a fixed prop of the dataset (eg. 'P1M' for monthly data) and comes straight from the config. With the current UI and architecture, users never change it and the backend (I think) doesn’t treat it as a dynamic input. Because of that, we don't have to include it in the key here.
| } | ||
|
|
||
| export async function requestCMRTimeseriesData({ | ||
| async function requestCMRTimeseriesData({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the cleanup! I agree with removing the export. We generally rely on module scope (exported vs. non-exported) to signal privacy rather than using naming prefixes like private_.
I think if we ever need to reuse this logic elsewhere, we should extract it into a dedicated util file or custom hook at that point. But for now, keeping it non-exported here is perfect.
- # Changelog - ## 🎉 Features - feat: Expose VedaMap [#1878](NASA-IMPACT/veda-ui#1878) - feat: migrate ExternalLinkFlag to USWDS [#1887](NASA-IMPACT/veda-ui#1887) - feat: Share button to URL shortener [#1905](NASA-IMPACT/veda-ui#1905) - feat: embed mode for e&a [#1922](NASA-IMPACT/veda-ui#1922) - ## 🚀 Improvements - chore: trigger netlify redeploy - refactor: Preset selector [#1874](NASA-IMPACT/veda-ui#1874) - refactor: retire Collecticons [#1893](NASA-IMPACT/veda-ui#1893) - refactor: migrate dataset layer card icons to USWDS [#1891](NASA-IMPACT/veda-ui#1891) - refactor: Replace Collecticons in legacy footer and connections section [#1890](NASA-IMPACT/veda-ui#1890) - refactor: migrate catalog components to USWDS (except catalog-card) [#1888](NASA-IMPACT/veda-ui#1888) - ci: prevent cleanup from deleting latest valid release tag [#1910](NASA-IMPACT/veda-ui#1910) - ci: disable the slack notifications until we stabilize the release workflow [#1909](NASA-IMPACT/veda-ui#1909) - ci: re-enable slack notifications for failed releases [#1911](NASA-IMPACT/veda-ui#1911) - docs: Update development instructions for storybook [#1914](NASA-IMPACT/veda-ui#1914) - test: Add micasa to mock datasets for testing cmr timeseries [#1896](NASA-IMPACT/veda-ui#1896) - ## 📊 Dataset Updates - fix: Updates for SEDAC dataset landing page[#840](#840) - ## 📝 Stories Updates - ## 🐛 Fixes - fix: make release workflow idempotent and reset version to last successful release [#1908](NASA-IMPACT/veda-ui#1908) - fix: wmts copy url [#1886](NASA-IMPACT/veda-ui#1886) - fix: 744/search bar fix [#1903](NASA-IMPACT/veda-ui#1903) - fix: Rename React component files from .js to .jsx [#1901](NASA-IMPACT/veda-ui#1901) - fix: migrate scrollytelling from CollecticonCircleXmark to USWDS [#1885](NASA-IMPACT/veda-ui#1885) - fix: remove Collecticons from EmptyHub and TimelineZoomControls components [#1884](NASA-IMPACT/veda-ui#1884) - fix: [veda-ui-1864] Update colormapscale to default to mdx rescale [#1916](NASA-IMPACT/veda-ui#1916) - fix: properly load API_URL_SHORTENER_ENDPOINT through VedaUI context [#1924](NASA-IMPACT/veda-ui#1924) - fix: Guided tour doesn't work in exported ExplorationAndAnalysis component [#1921](NASA-IMPACT/veda-ui#1921) - fix: selected pill alignment in data-catalog layer component [1932](NASA-IMPACT/veda-ui#1932) - fix: update compare swiper interactions to prevent interaction with map controls [#1930](NASA-IMPACT/veda-ui#1930) - fix: guard WMS date domain lookup in scrollytelling [1926](NASA-IMPACT/veda-ui#1926) - fix: update cmr query key to cache bust on start and end date [#1928](NASA-IMPACT/veda-ui#1928) - fix: add missing export for embedded exploration [#1933](NASA-IMPACT/veda-ui#1933) - fix: 1068 update mapbox compare [#1947](NASA-IMPACT/veda-ui#1947) - fix: Fix EMIT Bug with Overlapping Plumes [#798](US-GHG-Center/ghgc-architecture#798)
Related Ticket:
Closes: #1897
Description of Changes
Updated the query key on the CMR time series stats endpoint to include start and end date for cache bust. This will refetch, even if the new date range stats was included in the prior fetch, so this isn't as optimized as it could be for caching. But this was the simplest approach without adding additional logic to check if the dates were exclusive of the previously set range.
Notes & Questions About Changes
Curious if there are other parameters missing in this query key that should be added?
Validation / Testing
This would impact any CMR dataset available for timeseries analysis. I tested using the original branch the bug was reported on as this branch provided the CMR dataset for testing. When going through every dataset available on veda-ui in my local env, I was unable to find a valid CMR dataset. I suggest pulling in the commit
46eb610bd5d0e3f6eef29b8cf62a74d05e1b7ad8from the bug report branch into your local to test.