Skip to content

Data Insights: fetch total_data_assets once on the Data Assets tab (backport 2.0 #36452) - #36651

Merged
ShaileshParmar11 merged 1 commit into
2.0from
backport/2.0/pr-36452
Oct 30, 2026
Merged

ShaileshParmar11 merged 1 commit into
2.0from
backport/2.0/pr-36452

Conversation

@ShaileshParmar11

Copy link
Copy Markdown
Contributor

Describe your changes:

Backport of #36452 to 2.0: cherry-pick of 7d46ff41928 (git cherry-pick -x). No linked issue; this fixes a performance problem Sentry reported in production (COLLATE-FRONTEND-2A, "N+1 API Call" on /data-insights/data-assets).

On the Data Insights → Data Assets tab, every chart card fetched the total_data_assets series on its own with identical parameters: 5 times per load and 5 more on every filter change, each before the card's own request. DataAssetsTab now fetches it once and passes it to the cards; the percentage cards fetch their own chart and absolute-values chart in parallel. DataInsightProvider moves from pages/DataInsightPage/ to components/DataInsight/DataInsightProvider/, with a re-export left at the old path for openmetadata-collate. Full description and test notes are on #36452.

Conflicts resolved. On 2.0 the Data Insight UI still uses antd (Row/Col, antd Card with loading) and recharts; main uses core components. The logic was ported onto the 2.0 files and the 2.0 rendering kept:

  • DataInsightChartCard.tsx: the 2.0 card, with the same changes as on main — totalAssets prop, getCardDataState, parallel fetchData in useCallback, the full changeInValue memo dependencies, and the void fetchData() effect. While the shared totals load, the antd Card shows its loading skeleton, as it did for the card's own request.
  • DataAssetsTab.component.tsx: the 2.0 antd layout, plus the single total_data_assets fetch with the stale-response guard, passed to the same 5 cards.
  • AppAnalyticsTab.component.tsx, DataInsightHeader.component.tsx: kept the 2.0 imports; only the provider import path changes.
  • DataInsightChartCard.test.tsx does not exist on 2.0, and the main version asserts on the core LineChart. The 4 tests for this fix are rewritten against the 2.0 card (graph data-testid instead of LineChart props); the main-only chart rendering tests are not carried over.
  • The moved DataInsightProvider.tsx and DataInsight.interface.ts are identical on 2.0 and main apart from import paths.

Type of change:

  • Bug fix

Tests:

Unit tests

  • DataAssetsTab.test.tsx cherry-picked unchanged (3 tests); DataInsightChartCard.test.tsx rewritten for 2.0 (4 tests).
  • Results on this branch, with the 2.0 dependencies (yarn install --frozen-lockfile): yarn test src/components/DataInsight src/pages/DataInsightPage: 12 suites, 29 tests passed.
  • Against the 2.0 DataInsightChartCard.tsx and DataAssetsTab.component.tsx without the fix, 6 of the 7 new tests fail (the remaining one, no fetch while KPIs load, held before too).

Backend integration tests

  • Not applicable (no backend API changes).

Playwright (UI) tests

Manual testing performed

  • The CI checkstyle sequence (organize-imports, eslint --fix, prettier --write) on the changed files leaves no diff; ESLint reports 0 errors.
  • tsc --noEmit: no errors in the changed files. The errors it reports are in existing files this PR does not touch (e.g. TasksUtils.test.tsx).
  • Not checked in a running app on 2.0.

UI screen recording:

Not applicable — backport of a performance bug fix with no visual change.

Checklist:

  • I have read the CONTRIBUTING document.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Decision check: no decision record needed.

🤖 Generated with Claude Code

…36452)

* 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)
@ShaileshParmar11 ShaileshParmar11 added UI UI specific issues safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check labels Oct 30, 2026
@gitar-bot

gitar-bot Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Fetching shared total-assets data once changes filter-driven chart loading; a failed request could leave all five Data Insights cards empty.

Backport of the Data Insights fix that fetches total_data_assets once on the Data Assets tab instead of once per chart card, removing the N+1 API calls reported in Sentry. DataAssetsTab passes the shared totals to the five cards, and DataInsightProvider moves to components/DataInsight/DataInsightProvider/ with a re-export left at the old path. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@github-actions

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 68%
68.51% (83324/121610) 53.48% (51749/96752) 54.18% (15372/28372)

@sonarqubecloud

Copy link
Copy Markdown

This branch was successfully deployed

1 active deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs skip-pr-checks Bypass PR metadata validation check UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants