Skip to content

Commit

Permalink
fix(glossary) Improve business glossary loading performance (#6208)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscollins3456 committed Oct 14, 2022
1 parent 5a2bdea commit 034f2e9
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 26 deletions.
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/entity/glossaryNode/ChildrenTab.tsx
Expand Up @@ -11,6 +11,8 @@ function ChildrenTab() {
const { entityData } = useEntityData();
const entityRegistry = useEntityRegistry();

if (!entityData) return <></>;

const childNodes = entityData?.children?.relationships
.filter((child) => child.entity?.type === EntityType.GlossaryNode)
.sort((nodeA, nodeB) => sortGlossaryNodes(entityRegistry, nodeA.entity, nodeB.entity))
Expand Down
60 changes: 40 additions & 20 deletions datahub-web-react/src/app/glossary/GlossaryBrowser/NodeItem.tsx
@@ -1,4 +1,4 @@
import { FolderOutlined, RightOutlined, DownOutlined } from '@ant-design/icons';
import { FolderOutlined, RightOutlined, DownOutlined, LoadingOutlined } from '@ant-design/icons';
import styled from 'styled-components/macro';
import React, { useState, useEffect } from 'react';
import { ANTD_GRAY } from '../../entity/shared/constants';
Expand Down Expand Up @@ -45,6 +45,17 @@ const ChildrenWrapper = styled.div`
padding-left: 12px;
`;

const LoadingWrapper = styled.div`
padding: 8px;
display: flex;
justify-content: center;
svg {
height: 15px;
width: 15px;
}
`;

interface Props {
node: GlossaryNode;
isSelecting?: boolean;
Expand All @@ -63,7 +74,7 @@ function NodeItem(props: Props) {
const [areChildrenVisible, setAreChildrenVisible] = useState(false);
const entityRegistry = useEntityRegistry();
const { entityData } = useEntityData();
const { data } = useGetGlossaryNodeQuery({
const { data, loading } = useGetGlossaryNodeQuery({
variables: { urn: node.urn },
skip: !areChildrenVisible || shouldHideNode,
});
Expand Down Expand Up @@ -126,24 +137,33 @@ function NodeItem(props: Props) {
</NameWrapper>
)}
</NodeWrapper>
{areChildrenVisible && data && data.glossaryNode && (
<ChildrenWrapper>
{(childNodes as GlossaryNode[]).map((child) => (
<NodeItem
node={child}
isSelecting={isSelecting}
hideTerms={hideTerms}
openToEntity={openToEntity}
nodeUrnToHide={nodeUrnToHide}
selectTerm={selectTerm}
selectNode={selectNode}
/>
))}
{!hideTerms &&
(childTerms as GlossaryTerm[]).map((child) => (
<TermItem term={child} isSelecting={isSelecting} selectTerm={selectTerm} />
))}
</ChildrenWrapper>
{areChildrenVisible && (
<>
{!data && loading && (
<LoadingWrapper>
<LoadingOutlined />
</LoadingWrapper>
)}
{data && data.glossaryNode && (
<ChildrenWrapper>
{(childNodes as GlossaryNode[]).map((child) => (
<NodeItem
node={child}
isSelecting={isSelecting}
hideTerms={hideTerms}
openToEntity={openToEntity}
nodeUrnToHide={nodeUrnToHide}
selectTerm={selectTerm}
selectNode={selectNode}
/>
))}
{!hideTerms &&
(childTerms as GlossaryTerm[]).map((child) => (
<TermItem term={child} isSelecting={isSelecting} selectTerm={selectTerm} />
))}
</ChildrenWrapper>
)}
</>
)}
</ItemWrapper>
);
Expand Down
Expand Up @@ -27,7 +27,7 @@ function GlossaryEntitiesList(props: Props) {
name={node.properties?.name || ''}
urn={node.urn}
type={node.type}
count={(node as GlossaryNodeFragment).children?.count}
count={(node as GlossaryNodeFragment).children?.total}
/>
))}
{terms.map((term) => (
Expand Down
4 changes: 2 additions & 2 deletions datahub-web-react/src/graphql/fragments.graphql
Expand Up @@ -19,8 +19,8 @@ fragment glossaryNode on GlossaryNode {
properties {
name
}
children: relationships(input: { types: ["IsPartOf"], direction: INCOMING, start: 0, count: 1000 }) {
count
children: relationships(input: { types: ["IsPartOf"], direction: INCOMING, start: 0, count: 10000 }) {
total
}
}

Expand Down
14 changes: 11 additions & 3 deletions datahub-web-react/src/graphql/glossaryNode.graphql
@@ -1,3 +1,11 @@
fragment childGlossaryTerm on GlossaryTerm {
name
hierarchicalName
properties {
name
}
}

query getGlossaryNode($urn: String!) {
glossaryNode(urn: $urn) {
urn
Expand All @@ -17,19 +25,19 @@ query getGlossaryNode($urn: String!) {
types: ["IsPartOf"]
direction: INCOMING
start: 0
count: 1000
count: 10000
}
) {
count
relationships {
direction
entity {
type
urn
... on GlossaryNode {
...glossaryNode
}
... on GlossaryTerm {
...glossaryTerm
...childGlossaryTerm
}
}
}
Expand Down

0 comments on commit 034f2e9

Please sign in to comment.