Fixed #333 sort frequently used tables based on usage. (#341)

This commit is contained in:
Sachin Chaurasiya 2021-08-31 11:27:19 +05:30 committed by GitHub
parent 32b8bea8c2
commit 48d6776240
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,19 +28,21 @@ type Props = {
const viewCap = 3; const viewCap = 3;
const getUniqueTablesWithCount = (tableFQNs: Props['tableList']) => { const getUniqueTablesWithCount = (tableFQNs: Props['tableList']) => {
return tableFQNs.reduce((resList, curr) => { return tableFQNs
let duplicates = false; .reduce((resList, curr) => {
for (const table of resList) { let duplicates = false;
if (table.fqn === curr.fqn) { for (const table of resList) {
table.joinCount += curr.joinCount; if (table.fqn === curr.fqn) {
duplicates = true; table.joinCount += curr.joinCount;
duplicates = true;
break; break;
}
} }
}
return duplicates ? resList : [...resList, curr]; return duplicates ? resList : [...resList, curr];
}, [] as Props['tableList']); }, [] as Props['tableList'])
.sort((a, b) => (a.joinCount < b.joinCount ? 1 : -1));
}; };
const FrequentlyJoinedTables: FunctionComponent<Props> = ({ const FrequentlyJoinedTables: FunctionComponent<Props> = ({