mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 12:43:58 +00:00
SYNC: diagram improvements
This commit is contained in:
committed by
Diflow
parent
a81d66ace3
commit
b8b1412bf8
@@ -1,21 +1,24 @@
|
|||||||
import { DatabaseInfo, TableInfo } from 'dbgate-types';
|
import { DatabaseInfo, TableInfo } from 'dbgate-types';
|
||||||
import { extendDatabaseInfo } from './structureTools';
|
import { extendDatabaseInfo } from './structureTools';
|
||||||
import _sortBy from 'lodash/sortBy';
|
import _sortBy from 'lodash/sortBy';
|
||||||
|
import _uniq from 'lodash/uniq';
|
||||||
import { filterName } from './filterName';
|
import { filterName } from './filterName';
|
||||||
|
|
||||||
function tableWeight(table: TableInfo, maxRowcount?: number) {
|
function tableWeight(table: TableInfo, maxRowcount?: number) {
|
||||||
let weight = 0;
|
let weight = 0;
|
||||||
|
const tableDependenciesCount = _uniq(table.dependencies?.map(x => x.pureName) || []).length;
|
||||||
|
const tableFkCount = _uniq(table.foreignKeys?.map(x => x.refTableName) || []).length;
|
||||||
|
|
||||||
if (table.primaryKey) weight += 1;
|
if (table.primaryKey) weight += 1;
|
||||||
if (table.foreignKeys) weight += table.foreignKeys.length * 1;
|
if (tableFkCount) weight += tableFkCount * 1;
|
||||||
if (maxRowcount && table.tableRowCount) {
|
if (maxRowcount && table.tableRowCount) {
|
||||||
const rowcount = parseInt(table.tableRowCount as string);
|
const rowcount = parseInt(table.tableRowCount as string);
|
||||||
if (rowcount > 0)
|
if (rowcount > 0)
|
||||||
weight +=
|
weight += Math.log(rowcount) * table.columns.length * (tableFkCount || 1) * (tableDependenciesCount || 1);
|
||||||
Math.log(rowcount) * table.columns.length * (table.dependencies.length || 1) * (table.dependencies.length || 1);
|
|
||||||
} else {
|
} else {
|
||||||
if (table.columns) weight += table.columns.length * 2;
|
if (table.columns) weight += table.columns.length * 2;
|
||||||
}
|
}
|
||||||
if (table.dependencies) weight += table.dependencies.length * 10;
|
if (table.dependencies) weight += tableDependenciesCount * 10;
|
||||||
if (maxRowcount) return weight;
|
if (maxRowcount) return weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -944,12 +944,13 @@
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// $: if (onReportCounts) {
|
$: if (onReportCounts) {
|
||||||
// onReportCounts({
|
// console.log('REPORTING COUNTS');
|
||||||
// all: value?.tables?.length ?? 0,
|
onReportCounts({
|
||||||
// filtered: tables?.length ?? 0,
|
all: _.compact(value?.tables || []).length,
|
||||||
// });
|
filtered: _.compact(tables || []).length,
|
||||||
// }
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -119,6 +119,10 @@
|
|||||||
{ command: 'diagram.redo' },
|
{ command: 'diagram.redo' },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleReportCounts(counts) {
|
||||||
|
tableCounts = counts;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ToolStripContainer>
|
<ToolStripContainer>
|
||||||
@@ -131,9 +135,7 @@
|
|||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
menu={createMenu}
|
menu={createMenu}
|
||||||
columnFilter={$styleStore.columnFilter}
|
columnFilter={$styleStore.columnFilter}
|
||||||
onReportCounts={counts => {
|
onReportCounts={handleReportCounts}
|
||||||
tableCounts = counts;
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
<svelte:fragment slot="2">
|
<svelte:fragment slot="2">
|
||||||
|
|||||||
Reference in New Issue
Block a user