Repository navigation
chore(ui): load entity feed and task counts through one useEntityFeedCounts hook - #39791
harsh-vador wants to merge 3 commits into
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
341861e to
a389f5e
Compare
Playwright full suite on the activity feed cleanup stackPR CI skips Playwright here, so I ran the whole suite on the stack instead (
|
a389f5e to
b9f6550
Compare
… counts The hook loads an entity's task counts and its activity and conversation counts as two React Query queries, so one failing request leaves the other count in place and pages share the cached counts. It returns the feedCount, getEntityFeedCount and handleFeedCount the pages already pass down. getFeedCounts keeps its callback form for Collate, now built on the same fetchers; the unused domain overload is dropped.
…eedCounts Each page held its own feedCount state, a getFeedCounts reload and two fetchers writing into that state. They now call the hook with their entity type, fqn and the permission they already checked; the test case page asks for task counts only. Pages that refetched every count when their permissions loaded now fetch once. The tag page still reloads the counts after a tag update. fetchEntityTaskCountsInto and fetchEntityActivityCountInto had no other caller and are removed.
After the entity pages moved to useEntityFeedCounts, openmetadata-collate is the only caller of getFeedCounts. Record that contract and cite it on the export, so a later cleanup does not delete it before Collate moves to the hook (openmetadata-collate#9311).
b9f6550 to
2c9209a
Compare
Code Review ✅ Approved 🟡 Medium risk 1 closed / 1 findingsMoving feed and task counts for 26 entity pages to React Query changes cache and reload behavior, so stale counts could mislead users. Replaces the duplicated per-page feed and task count logic across 26 entity pages with a single React Query-based ✅ 1 closed✅ Quality: Unrecorded cross-repo contract: getFeedCounts kept only for collate
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 |
Describe your changes:
Fixes https://github.com/open-metadata/openmetadata-collate/issues/9240
Before this PR, 26 entity pages each fetched their feed and task counts with the same copied block:
feedCountstate;getFeedCountsreload;fetchEntityTaskCountsInto,fetchEntityActivityCountInto);This PR replaces that block with one hook,
useEntityFeedCounts(entityType, fqn, { enabled, includeActivity }), built on React Query. In production code, about 900 more lines are removed than added. Part of the activity feed cleanup (open-metadata/openmetadata-collate#9236).Collate companion: open-metadata/openmetadata-collate#9312 (draft) moves Collate's last
getFeedCountscaller to this hook. It merges after this PR.Stacked on #39779 (→ #39733 → #39670). This PR targets
chore/feed-small-dups, so the diff shows only these two commits. It is retargeted tomainonce the PRs below it merge.feedCount,getEntityFeedCountandhandleFeedCount, the names the pages already pass to their tabs and class bases, so no child component changes.getFeedCountsstays exported because Collate calls it, and it now uses the same fetchers. Itsdomainoverload had no caller and is removed.enabled. The test case page only shows the open-task count, so it passesincludeActivity: false.fetchEntityTaskCountsIntoandfetchEntityActivityCountIntohad no other caller and are removed.What a user or reviewer can notice:
getEntityFeedCount(after a post, a task change, a tag update).staleTime0, as everywhere else in the app).onTasksChangeused to reload only the task counts. It now reloads both, which is one more request after a task change.Type of change:
High-level design:
One hook, two React Query keys:
['entityFeedCounts', 'tasks', fqn]and['entityFeedCounts', 'activity', entityType, fqn].handleFeedCountwrites a fullFeedCountsinto both keys, andgetEntityFeedCountrefetches the enabled ones. An error shows the sameserver.entity-feed-fetch-errortoast as before.Tests:
Use cases covered
enabled: false, or without an fqn, it sends nothing, including throughgetEntityFeedCount.includeActivity: false, it loads and reloads only the task counts.getEntityFeedCountreloads every count, andhandleFeedCountreplaces them.Unit tests
hooks/useEntityFeedCounts.test.tsx: 7 tests.utils/FeedUtilsPure.getFeedCounts.test.tsnow coversfetchEntityActivityCounts.enabledandincludeActivity.components/ActivityFeed, the hook and the utils.tsc: no new errors. The 38 that remain are onmain, in four unrelated test files.Before / after
Captured against a local backend with the same data, before (the base branch files) and after (this branch):
9240-feed-counts.png:UI screen recording:
Not applicable: a refactor with no visual change, with the before/after capture above.
Checklist:
Fixes <issue-number>: <short explanation>. The issue is in openmetadata-collate, so the title names the area instead.Fixesabove.REVIEW.mdand fixed every 🔴 finding, or answered it on the line below.getFeedCounts, whose callback form is unchanged.getEntityFeedCountandhandleFeedCount. Outside these files, Collate uses them only in its ownPipelineDetails, which callsgetFeedCounts.docs/decisions/. ADR:2026-12-04-getfeedcounts-is-kept-for-collate records thatgetFeedCountsstays exported, in its callback form, until open-metadata/openmetadata-collate#9311 moves Collate's last caller to the hook. The JSDoc on the export cites it.🤖 Generated with Claude Code