Skip to content

Commit

Permalink
Merge pull request #1949 from upalatucci/storage-utilization-fix
Browse files Browse the repository at this point in the history
CNV-41600: Storage utilization fix
  • Loading branch information
openshift-merge-bot[bot] authored May 19, 2024
2 parents a1c74aa + d9c51cf commit 5121041
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/utils/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ export const columnSorting = <T>(
return data?.sort(predicate)?.slice(startIndex, endIndex);
};

export const removeDuplicatesByName = (array: any[]) =>
export const removeDuplicatesByName = (array: any[], nameProperty = 'name') =>
array?.reduce((acc, curr) => {
if (!acc.find((item) => item?.name === curr?.name)) acc.push(curr);
if (!acc.find((item) => item?.[nameProperty] === curr?.[nameProperty])) acc.push(curr);
return acc;
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const StorageUtil: FC<StorageUtilProps> = ({ vmi }) => {
const [guestAgentData, loaded] = useGuestOS(vmi);

const { totalBytes = 0, usedBytes = 0 } =
removeDuplicatesByName(guestAgentData?.fsInfo?.disks)?.reduce(
removeDuplicatesByName(guestAgentData?.fsInfo?.disks, 'diskName')?.reduce(
(acc, data) => {
acc.totalBytes += data?.totalBytes;
acc.usedBytes += data?.usedBytes;
Expand Down

0 comments on commit 5121041

Please sign in to comment.