Repository navigation
Data Insights: fetch total_data_assets once on the Data Assets tab - #36452
Conversation
Each chart card fetched the total_data_assets series on its own, so the tab sent the same request five times per load and per filter change, and each card waited on it before its own chart. The tab now fetches it once and passes it to the cards; each card fetches its own chart and absolute values in parallel.
A percentage card computed its change from an empty totals series while the shared total_data_assets request was in flight, or after it failed, and showed 0%. It now waits for the totals and shows the empty state if they failed.
|
| Count | Rule |
|---|---|
| 5 | react-hooks/exhaustive-deps |
| 1 | openmetadata-imports/no-api-calls-in-iteration |
All findings
| Location | Rule | Message | |
|---|---|---|---|
| 🟡 | src/components/DataInsight/DataInsightProvider/DataInsightProvider.tsx:284:5 |
react-hooks/exhaustive-deps |
React Hook useMemo has missing dependencies: 'selectedDaysFilter' and 'tier'. Either include them or remove the dependency array. |
| 🟡 | src/components/DataInsight/DataInsightProvider/DataInsightProvider.tsx:307:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has a missing dependency: 'fetchDefaultTeamOptions'. Either include it or remove the dependency array. |
| 🟡 | src/components/DataInsight/DataInsightSummary.tsx:72:5 |
react-hooks/exhaustive-deps |
React Hook useMemo has an unnecessary dependency: 'chartFilter'. Either exclude it or remove the dependency array. |
| 🟡 | src/components/DataInsight/DataInsightSummary.tsx:77:5 |
react-hooks/exhaustive-deps |
React Hook useMemo has an unnecessary dependency: 'chartFilter'. Either exclude it or remove the dependency array. |
| 🟡 | src/components/DataInsight/DataInsightSummary.tsx:148:16 |
openmetadata-imports/no-api-calls-in-iteration |
Avoid issuing one API request per item. Fetch at the data owner, use a bulk endpoint, or use useQueries with an intentional concurrency policy. |
| 🟡 | src/components/DataInsight/DataInsightSummary.tsx:179:6 |
react-hooks/exhaustive-deps |
React Hook useEffect has missing dependencies: 'fetchEntitiesChartData', 'fetchMostActiveUser', and 'fetchWebChartData'. Either include them or remove the depen |
Fix locally (fast - only checks files changed in this branch):
make ui-checkstyle-changed…nts stop importing a page openmetadata-collate still imports it from pages/DataInsightPage/DataInsightProvider, so that path stays as a re-export.
Code Review ✅ Approved🟡 Medium risk · Sharing filtered totals across Data Assets cards changes chart loading and calculations; stale or failed fetch handling could show incorrect or empty insights. Fetches VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
|
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
…36452) (#36571) * ui: fetch total_data_assets once on the Data Insights Data Assets tab Each chart card fetched the total_data_assets series on its own, so the tab sent the same request five times per load and per filter change, and each card waited on it before its own chart. The tab now fetches it once and passes it to the cards; each card fetches its own chart and absolute values in parallel. * ui: keep percentage cards loading until the shared totals arrive A percentage card computed its change from an empty totals series while the shared total_data_assets request was in flight, or after it failed, and showed 0%. It now waits for the totals and shows the empty state if they failed. * ci: map the Data Insight components to DataInsight.spec.ts * ui: assert the empty and loading states in the chart card tests * ui: list the chart card fetch effect's dependencies in full * ui: fetch the shared totals in an async function with try/catch * ui: mark the fire-and-forget fetches in the Data Insight effects as void * ui: drive the DataAssetsTab test's provider mock without importing the page * ui: move DataInsightProvider out of pages so the Data Insight components stop importing a page openmetadata-collate still imports it from pages/DataInsightPage/DataInsightProvider, so that path stays as a re-export. * ui: sort the moved Data Insight provider's imports (cherry picked from commit 7d46ff4) Co-authored-by: Shailesh Parmar <shailesh.parmar.webdev@gmail.com>
…36452) (#36651) * ui: fetch total_data_assets once on the Data Insights Data Assets tab Each chart card fetched the total_data_assets series on its own, so the tab sent the same request five times per load and per filter change, and each card waited on it before its own chart. The tab now fetches it once and passes it to the cards; each card fetches its own chart and absolute values in parallel. * ui: keep percentage cards loading until the shared totals arrive A percentage card computed its change from an empty totals series while the shared total_data_assets request was in flight, or after it failed, and showed 0%. It now waits for the totals and shows the empty state if they failed. * ci: map the Data Insight components to DataInsight.spec.ts * ui: assert the empty and loading states in the chart card tests * ui: list the chart card fetch effect's dependencies in full * ui: fetch the shared totals in an async function with try/catch * ui: mark the fire-and-forget fetches in the Data Insight effects as void * ui: drive the DataAssetsTab test's provider mock without importing the page * ui: move DataInsightProvider out of pages so the Data Insight components stop importing a page openmetadata-collate still imports it from pages/DataInsightPage/DataInsightProvider, so that path stays as a re-export. * ui: sort the moved Data Insight provider's imports (cherry picked from commit 7d46ff4)



Describe your changes:
No linked issue; this fixes a performance problem Sentry reported in production (COLLATE-FRONTEND-2A, "N+1 API Call" on
/data-insights/data-assets). Labelledskip-pr-checks.On the Data Insights → Data Assets tab, every chart card fetched the
total_data_assetsseries on its own, with identicalstart,endandfilter. The tab sent that request 5 times per load and 5 more on every filter change. Each card also waited for it before fetching its own chart, one request after another.DataAssetsTabfetchestotal_data_assetsonce per filter change and passes it to the cards astotalAssets. A response that a newer filter has superseded is ignored.Promise.all). They stay in the loading state until the shared totals arrive, so they never show a 0% change computed from an empty series. If the totals request fails, they show the empty state, as they did before when the request inside each card failed.changeInValuememo listed onlychartData.resultsas a dependency. It also readstotalAssetsandabsoluteValues, which now arrive separately, so they are added.DataInsightProviderand its interface move frompages/DataInsightPage/tocomponents/DataInsight/DataInsightProvider/, so the Data Insight components no longer import a page (no-lower-layer-page-imports).openmetadata-collateimports the provider from the old path inDashboardChart.tsxandDashboardDetails.tsx, sopages/DataInsightPage/DataInsightProvider.tsxstays as a re-export. The provider's code is unchanged..github/playwright/impact-map.jsonmapscomponents/DataInsight/**andpages/DataInsightPage/**toDataInsight.spec.ts; these files were unmapped and would have run the full suite.Requests on load go from 15 (largely sequential) to 11, with no duplicates. The tier card is unchanged.
Type of change:
High-level design:
N/A — small change.
Tests:
Use cases covered
total_data_assetsonce and hands the same object to the five cards that read it.nullwhen the totals request fails, and does not fetch while the KPIs are loading.total_data_assets.Unit tests
src/components/DataInsight/DataAssetsTab/DataAssetsTab.test.tsx(new, 3 tests)src/components/DataInsight/DataInsightChartCard.test.tsx(4 new tests)yarn test src/components/DataInsight: 10 suites, 38 tests passed.DataAssetsTab.component.tsx100% lines;DataInsightChartCard.tsx85% lines. The uncovered lines are pre-existing (computeTotalDataAssetsByTierChange, thetargetValue/totalValueswitch, the legend mouse handlers).main, 3 against the first commit of this PR).tsc --noEmit: no errors in the changed files. ESLint: 0 errors. Prettier: clean.Backend integration tests
Ingestion integration tests
Playwright (UI) tests
DataInsight.spec.tscovers the tab rendering its graphs.playwright/e2e/Pages/DataInsight.spec.ts(projectData Insight) locally onb8b58e2b97b, against the Vite dev server for this branch and a local OSS backend (PLAYWRIGHT_IS_OSS=true): 14 passed (setup, entity data, Data Insight app run, 10@data-insighttests, teardown) in 1.5m.make playwright_affectedalso lists. None of them touches Data Insight.Manual testing performed
On the same local stack, after the Data Insight app had run (80 data assets):
total_data_assets1 (was 5), 10system/charts/name/*/datarequests plus 1listChartData. The dev build renders underReact.StrictMode, so every request appears twice there; a production build mounts once.UI screen recording:
Not applicable — performance bug fix with no visual change.
Checklist:
I have read the CONTRIBUTING document.
My PR title is
Fixes <issue-number>: <short explanation>— no issue; Sentry-reported fix, labelledskip-pr-checks.My PR is linked to a GitHub issue via
Fixes #<issue-number>above — see above.I have commented on my code, particularly in hard-to-understand areas.
For JSON Schema changes: not applicable.
For a UI feature or feature task: not applicable (bug fix).
I have added tests (unit / integration / Playwright as applicable) and listed them above.
Self-review: I reviewed the final diff against
REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.8adda704e30; test-only commitadd32800eb2follows. The first pass found one 🔴: percentage cards showed a 0% change while the totals were loading or after they failed. Fixed in8adda704e30, with tests. The second pass found no 🔴.totalAssetsis optional rather than required per card type (one caller today); no test asserts the computedchangeInValuevalue.Decision check: no durable decision; nothing to record.
I have added a test that covers the exact scenario we are fixing.
🤖 Generated with Claude Code