mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 18:16:00 +00:00
SYNC: autodetect - with grouping field
This commit is contained in:
@@ -3,12 +3,23 @@ import _sum from 'lodash/sum';
|
||||
import { ChartLimits, ChartYFieldDefinition, ProcessedChart } from './chartDefinitions';
|
||||
|
||||
export function getChartScore(chart: ProcessedChart): number {
|
||||
if (chart.errorMessage) {
|
||||
return -1; // negative score for charts with errors
|
||||
}
|
||||
let res = 0;
|
||||
res += chart.rowsAdded * 5;
|
||||
|
||||
const ydefScores = chart.definition.ydefs.map(yField => getChartYFieldScore(chart, yField));
|
||||
const sorted = _sortBy(ydefScores).reverse();
|
||||
res += _sum(sorted.slice(0, ChartLimits.AUTODETECT_MEASURES_LIMIT));
|
||||
|
||||
if (chart.groupSet?.size >= 2 && chart.groupSet?.size <= 6) {
|
||||
res += 50; // bonus for nice grouping
|
||||
}
|
||||
if (chart.groupSet?.size == 1) {
|
||||
res -= 20; // penalty for single group
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user