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 getUniqueTablesWithCount = (tableFQNs: Props['tableList']) => {
return tableFQNs.reduce((resList, curr) => {
let duplicates = false;
for (const table of resList) {
if (table.fqn === curr.fqn) {
table.joinCount += curr.joinCount;
duplicates = true;
return tableFQNs
.reduce((resList, curr) => {
let duplicates = false;
for (const table of resList) {
if (table.fqn === curr.fqn) {
table.joinCount += curr.joinCount;
duplicates = true;
break;
break;
}
}
}
return duplicates ? resList : [...resList, curr];
}, [] as Props['tableList']);
return duplicates ? resList : [...resList, curr];
}, [] as Props['tableList'])
.sort((a, b) => (a.joinCount < b.joinCount ? 1 : -1));
};
const FrequentlyJoinedTables: FunctionComponent<Props> = ({