Skip to content

Commit

Permalink
Merge pull request #424 from DataRecce/feature/drc-628-make-actions-t…
Browse files Browse the repository at this point in the history
…ogether

Make the node actions together
  • Loading branch information
popcornylu authored Sep 20, 2024
2 parents df07719 + bb69cde commit 8d1c704
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 162 deletions.
8 changes: 1 addition & 7 deletions js/src/components/lineage/ActionTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,7 @@ export const ActionTag = ({ node, action }: ActionTagProps) => {

if (run.type === "row_count_diff") {
const result = run.result as RowCountDiffResult;
return (
<RowCountTag
rowCount={result[node.name]}
node={node}
isInteractive={false}
/>
);
return <RowCountTag rowCount={result[node.name]} node={node} />;
}

return <>{run_id}</>;
Expand Down
2 changes: 1 addition & 1 deletion js/src/components/lineage/NodeFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ const MoreActionMenu = (props: NodeFilterProps) => {
</MenuItem>
</MenuGroup>
<MenuDivider />
<MenuGroup title="Add check" m="0" px="12px">
<MenuGroup title="Add to Checklist" m="0" px="12px">
<MenuItem
as={Text}
size="sm"
Expand Down
26 changes: 9 additions & 17 deletions js/src/components/lineage/NodeTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,33 +106,25 @@ export function ModelRowCount({ rowCount }: ModelRowCountProps) {
export interface RowCountTagProps {
node: LineageGraphNode;
rowCount?: RowCount;
isInteractive?: boolean; // if true, allows user to manually fetch row count
onRefresh?: () => Promise<any>;
isFetching?: boolean;
error?: Error | null;
}

export function RowCountTag({
rowCount: defaultRowCount,
rowCount: fetchedRowCount,
node,
isInteractive,
onRefresh,
isFetching,
}: RowCountTagProps) {
const { runsAggregated, refetchRunsAggregated } = useLineageGraphContext();
const lastRowCount: RowCount | undefined =
runsAggregated?.[node.id]?.["row_count_diff"]?.result;

const {
data: fetchedRowCount,
refetch: invokeRowCountQuery,
isFetching,
} = useQuery({
queryKey: cacheKeys.rowCount(node.name),
queryFn: () => queryModelRowCount(node.name),
enabled: false,
initialData: defaultRowCount,
});

const rowCount = fetchedRowCount || defaultRowCount || lastRowCount;
const icon = findByRunType("row_count_diff")?.icon;

let label;
const rowCount = fetchedRowCount || lastRowCount;
if (rowCount) {
const base = rowCount?.base === null ? "N/A" : rowCount?.base;
const current = rowCount?.curr === null ? "N/A" : rowCount?.curr;
Expand All @@ -158,15 +150,15 @@ export function RowCountTag({
<>row count</>
)}
</TagLabel>
{isInteractive && (
{onRefresh && (
<TagRightIcon
as={IconButton}
isLoading={isFetching}
aria-label="Query Row Count"
icon={<RepeatIcon />}
size="xs"
onClick={async () => {
await invokeRowCountQuery();
await onRefresh();
refetchRunsAggregated?.();
}}
/>
Expand Down
Loading

0 comments on commit 8d1c704

Please sign in to comment.