-
Notifications
You must be signed in to change notification settings - Fork 15.7k
feat(frontend): add dataset cache clearing utilities and integration #35264
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
base: master
Are you sure you want to change the base?
Conversation
- Add datasetCache utility with functions to clear cached API responses - Integrate cache clearing in SaveDatasetModal after dataset updates - Integrate cache clearing in DatasourceModal and DatasourceEditor - Ensures fresh data is fetched after dataset modifications 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
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.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
Category | Issue | Status |
---|---|---|
Redundant and imprecise cache key matching ▹ view | 🧠 Not in standard | |
Invalid dataset ID 0 rejected by falsy check ▹ view | 🧠 Not in scope | |
Inefficient Two-Pass Cache Operation ▹ view | 🧠 Incorrect | |
Unawaited dataset cache clear ▹ view | 🧠 Not in scope |
Files scanned
File Path | Reviewed |
---|---|
superset-frontend/src/utils/datasetCache.ts | ✅ |
superset-frontend/src/components/Datasource/DatasourceModal/index.tsx | ✅ |
superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx | ✅ |
superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.jsx | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
export function clearDatasetCache(datasetId: number | string): void { | ||
if (!datasetId) return; | ||
|
||
const keysToDelete: string[] = []; | ||
|
||
// Find all cache keys related to this dataset | ||
supersetGetCache.forEach((_value, key) => { | ||
// Match any endpoint that references this dataset ID | ||
// This includes: | ||
// - /api/v1/dataset/{id} | ||
// - /api/v1/dataset/{id}?q=... | ||
// - /api/v1/dataset/{id}/related_objects | ||
// - etc. | ||
if ( | ||
key.includes(`/api/v1/dataset/${datasetId}`) || | ||
key.includes(`/api/v1/dataset/${datasetId}/`) || | ||
key.includes(`/api/v1/dataset/${datasetId}?`) | ||
) { | ||
keysToDelete.push(key); | ||
} | ||
}); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
if ( | ||
key.includes(`/api/v1/dataset/${datasetId}`) || | ||
key.includes(`/api/v1/dataset/${datasetId}/`) || | ||
key.includes(`/api/v1/dataset/${datasetId}?`) | ||
) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
* @param datasetId - The ID of the dataset to clear from cache | ||
*/ | ||
export function clearDatasetCache(datasetId: number | string): void { | ||
if (!datasetId) return; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
|
||
// Clear the dataset cache to ensure fresh data when fetching columns for filters | ||
// This ensures that changes to the dataset are immediately reflected | ||
clearDatasetCache(currentDatasource.id); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
SUMMARY
Implements dataset cache clearing functionality to ensure fresh data is fetched after dataset modifications. This addresses potential stale data issues where cached API responses were not being invalidated when datasets were updated.
Key Changes:
datasetCache.ts
utility with functions to clear cached API responses for specific datasetsSaveDatasetModal
after dataset updatesDatasourceModal
andDatasourceEditor
componentsBEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - This is a backend caching improvement with no visible UI changes
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION
🤖 Generated with Claude Code