dtable-statistic 4.0.2-test-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/es/api/dtable-db-api.js +43 -0
- package/es/assets/css/color-picker.css +53 -0
- package/es/assets/css/color-rules-popover.css +144 -0
- package/es/assets/css/color-theme-dialog.css +40 -0
- package/es/assets/css/dashboard.css +562 -0
- package/es/assets/css/dialog.css +415 -0
- package/es/assets/css/mobile-dashboard.module.css +91 -0
- package/es/assets/css/slider.css +77 -0
- package/es/assets/css/statistic-chart.module.css +11 -0
- package/es/assets/css/statistic-custom-title.module.css +3 -0
- package/es/assets/css/statistic-custom.module.css +4 -0
- package/es/assets/css/statistic-numeric-column-item.module.css +43 -0
- package/es/assets/css/statistic-time-picker.module.css +21 -0
- package/es/assets/css/theme.css +61 -0
- package/es/assets/images/icon.png +0 -0
- package/es/calculator/base-calculator.js +111 -0
- package/es/calculator/basic-chart-calculator.js +571 -0
- package/es/calculator/combination-calculator.js +296 -0
- package/es/calculator/compare-bar-calculator.js +291 -0
- package/es/calculator/completeness-calculator.js +307 -0
- package/es/calculator/copy-value.js +47 -0
- package/es/calculator/dashboard-calculator.js +146 -0
- package/es/calculator/heat-map-calculator.js +225 -0
- package/es/calculator/horizontal-bar-calculator.js +100 -0
- package/es/calculator/index.js +88 -0
- package/es/calculator/map-calculator.js +169 -0
- package/es/calculator/mirror-calculator.js +217 -0
- package/es/calculator/number-card-calculator.js +135 -0
- package/es/calculator/pivot-table-calculator.js +810 -0
- package/es/calculator/scatter-calculator.js +150 -0
- package/es/calculator/thread-manager.js +70 -0
- package/es/calculator/trend-calculator.js +204 -0
- package/es/calculator/workers/basic-chart-calculator-worker.js +410 -0
- package/es/calculator/workers/calculator.worker.js +22 -0
- package/es/calculator/workers/card-calculator-worker.js +28 -0
- package/es/calculator/workers/combination-calculator-worker.js +257 -0
- package/es/calculator/workers/compare-bar-chart-calculator-worker.js +149 -0
- package/es/calculator/workers/completeness-calculator-worker.js +153 -0
- package/es/calculator/workers/dashboard-calculator-worker.js +56 -0
- package/es/calculator/workers/mirror-calculator-worker.js +132 -0
- package/es/calculator/workers/pivot-table-calculator-worker.js +615 -0
- package/es/calculator/workers/scatter-calculator-worker.js +67 -0
- package/es/calculator/workers/trend-calculator-worker.js +93 -0
- package/es/calculator/world-map-calculator.js +193 -0
- package/es/components/common-add-tool.js +19 -0
- package/es/components/dialog/chart-addition-edit-dialog.js +89 -0
- package/es/components/dialog/chart-addition-widgets/chart-selector.js +261 -0
- package/es/components/dialog/chart-addition-widgets/statistic-chart-selector.module.css +74 -0
- package/es/components/dialog/color-theme-dialog.js +71 -0
- package/es/components/dialog/enlarged-chart-dialog.js +73 -0
- package/es/components/dialog/new-table-dialog.js +113 -0
- package/es/components/dialog/new-view-dialog.js +87 -0
- package/es/components/dialog/rename-view-dialog.js +87 -0
- package/es/components/dialog/statistic-record-dialog/index.css +114 -0
- package/es/components/dialog/statistic-record-dialog/index.js +174 -0
- package/es/components/dialog/table-select-dialog.js +93 -0
- package/es/components/dropdown-menu/statistic-dropdown-menu.js +94 -0
- package/es/components/dtable-popover.js +109 -0
- package/es/components/dtable-search-input.js +137 -0
- package/es/components/dtable-select.js +104 -0
- package/es/components/index.js +11 -0
- package/es/components/loading.js +8 -0
- package/es/components/modal-portal.js +36 -0
- package/es/components/popover/color-rules/color-rule.js +179 -0
- package/es/components/popover/color-rules/index.js +87 -0
- package/es/components/popover/color-rules/rule-filters/filter.js +214 -0
- package/es/components/popover/color-rules/rule-filters/index.css +214 -0
- package/es/components/popover/color-rules/rule-filters/index.js +97 -0
- package/es/components/popover/color-rules/rule-filters/number-input.js +85 -0
- package/es/components/popover/color-rules-popover.js +213 -0
- package/es/components/popover/color-selector-popover.js +85 -0
- package/es/components/seatable-radio/index.css +51 -0
- package/es/components/seatable-radio/index.js +28 -0
- package/es/components/select/index.js +2 -0
- package/es/components/select/option-group.css +104 -0
- package/es/components/select/option-group.js +225 -0
- package/es/components/select/option.js +51 -0
- package/es/components/select/select.css +211 -0
- package/es/components/select/select.js +157 -0
- package/es/components/toast/alert.js +130 -0
- package/es/components/toast/index.js +3 -0
- package/es/components/toast/toast.js +164 -0
- package/es/components/toast/toastManager.js +150 -0
- package/es/components/toast/toaster.js +64 -0
- package/es/constants/color-rules.js +8 -0
- package/es/constants/dtable-select-style.js +61 -0
- package/es/constants/event-types.js +1 -0
- package/es/constants/index.js +501 -0
- package/es/constants/key-codes.js +102 -0
- package/es/constants/zIndexes.js +1 -0
- package/es/custom-g2.js +614 -0
- package/es/dashboard.js +408 -0
- package/es/desktop-dashboard.js +299 -0
- package/es/index.js +33 -0
- package/es/locale/index.js +17 -0
- package/es/locale/lang/de.js +237 -0
- package/es/locale/lang/en.js +237 -0
- package/es/locale/lang/fr.js +237 -0
- package/es/locale/lang/zh_CN.js +237 -0
- package/es/mobile-dashboard.js +103 -0
- package/es/model/collaborators.js +11 -0
- package/es/model/stat-item.js +340 -0
- package/es/model/statistic-dashboard.js +8 -0
- package/es/service/chart-service.js +192 -0
- package/es/service/dashboard-service.js +415 -0
- package/es/stat-editor/chart-name-editor.js +75 -0
- package/es/stat-editor/index.js +74 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/basic-number-card-settings.js +149 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/combination-settings.js +415 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/dashboard-chart-settings.js +193 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/geo-granularity-settings.js +13 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/heat-map-settings.js +107 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/index.js +332 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/map-settings.js +170 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/mirror-settings.js +141 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/combination-style-setting.js +219 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/heat-map-settings.js +89 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/style-setting/map-setting.js +132 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/summary-settings.js +319 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/trend-chart-settings.js +138 -0
- package/es/stat-editor/stat-settings/advance-chart-settings/world-map-settings.js +135 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/advance-bar-chart-settings.js +156 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/bar-settings.js +147 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/completeness-chart-settings.js +195 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/custom-bar-settings.js +126 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/groupby-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-axis-group-settings.js +352 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-bar-settings.js +145 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/horizontal-group-chart-settings.js +153 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/index.js +466 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pie-settings.js +183 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/pivot-table-settings.js +542 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/scatter-settings.js +111 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stack-item-settings.js +86 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/stacks-settings.js +169 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/bar-chart-style-setting.js +273 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/completeness-style.js +105 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/horizontal-bar-chart-style.js +243 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/label-font-size-editor.js +65 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/pie-chart-style-settings.js +318 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/style-setting/time-compare-style.js +49 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-method-setting.js +124 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/summary-settings.js +150 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/time-comparison-settings.js +267 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/timer-picker.js +109 -0
- package/es/stat-editor/stat-settings/basic-chart-settings/y-axis-group-settings.js +351 -0
- package/es/stat-editor/stat-settings/color-setting/color-group-selector.js +60 -0
- package/es/stat-editor/stat-settings/color-setting/color-picker.js +129 -0
- package/es/stat-editor/stat-settings/color-setting/color-use-type-selector.js +348 -0
- package/es/stat-editor/stat-settings/public-setting/axis-label-position-setting.js +102 -0
- package/es/stat-editor/stat-settings/public-setting/base-settings.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/calender.js +124 -0
- package/es/stat-editor/stat-settings/public-setting/column-settings.js +15 -0
- package/es/stat-editor/stat-settings/public-setting/custom-title-setting.js +60 -0
- package/es/stat-editor/stat-settings/public-setting/data-sort-setting.js +57 -0
- package/es/stat-editor/stat-settings/public-setting/ind-toggle-setting.js +41 -0
- package/es/stat-editor/stat-settings/public-setting/min-max-setting.js +64 -0
- package/es/stat-editor/stat-settings/public-setting/numeric-summary-item.js +118 -0
- package/es/stat-editor/stat-settings/public-setting/toggle-setting.js +39 -0
- package/es/stat-list/chart-preview.js +139 -0
- package/es/stat-list/index.js +275 -0
- package/es/stat-view/area-chart.js +521 -0
- package/es/stat-view/bar-chart.js +568 -0
- package/es/stat-view/base-chart.js +44 -0
- package/es/stat-view/basic-number-card.js +255 -0
- package/es/stat-view/combination-chart.js +558 -0
- package/es/stat-view/compare-chart.js +485 -0
- package/es/stat-view/completeness-chart.js +389 -0
- package/es/stat-view/custom-bar.js +433 -0
- package/es/stat-view/dashboard-chart.js +317 -0
- package/es/stat-view/heat-map.js +501 -0
- package/es/stat-view/horizontal-bar-chart.js +569 -0
- package/es/stat-view/index.js +183 -0
- package/es/stat-view/line-chart.js +505 -0
- package/es/stat-view/map.js +428 -0
- package/es/stat-view/mirror.js +285 -0
- package/es/stat-view/pie-chart.js +326 -0
- package/es/stat-view/pivot-table/index.js +206 -0
- package/es/stat-view/pivot-table/one-dimension-table-no-numeric-columns.js +133 -0
- package/es/stat-view/pivot-table/one-dimension-table-with-numeric-columns.js +164 -0
- package/es/stat-view/pivot-table/statistic-pivot-table.module.css +132 -0
- package/es/stat-view/pivot-table/two-dimension-table.js +344 -0
- package/es/stat-view/ring-chart.js +416 -0
- package/es/stat-view/scatter-chart.js +367 -0
- package/es/stat-view/treemap-chart.js +318 -0
- package/es/stat-view/trend-chart.js +299 -0
- package/es/stat-view/world-map.js +443 -0
- package/es/tabs/index.js +252 -0
- package/es/tabs/statistic-tabs.module.css +154 -0
- package/es/tabs/tab.js +167 -0
- package/es/utils/basic-chart-utils.js +24 -0
- package/es/utils/cell-format.js +110 -0
- package/es/utils/cell-value.js +27 -0
- package/es/utils/collaborator.js +31 -0
- package/es/utils/color-utils.js +112 -0
- package/es/utils/column-utils.js +18 -0
- package/es/utils/column.js +13 -0
- package/es/utils/common-utils.js +303 -0
- package/es/utils/date-format.js +65 -0
- package/es/utils/export-table-utils.js +632 -0
- package/es/utils/index.js +26 -0
- package/es/utils/object.js +26 -0
- package/es/utils/row-utils.js +115 -0
- package/es/utils/search.js +67 -0
- package/es/utils/sql-utils.js +293 -0
- package/es/utils/stat-utils.js +353 -0
- package/es/utils/trend-utils.js +136 -0
- package/index.js +1 -0
- package/package.json +188 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
7
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
8
|
+
import { filter2SqlCondition, TableUtils } from 'dtable-store';
|
|
9
|
+
import BaseCalculator from './base-calculator';
|
|
10
|
+
import { getSqlGroup, getSqlOrder } from '../utils/sql-utils';
|
|
11
|
+
import { PIE_CHART_COLORS, STAT_TYPE, TIME_COLUMN_LIST } from '../constants';
|
|
12
|
+
import { isArrayCellValue } from '../utils/common-utils';
|
|
13
|
+
import StatUtils from '../utils/stat-utils';
|
|
14
|
+
import { getFormattedLabel } from '../utils/row-utils';
|
|
15
|
+
var CompletenessCalculator = /*#__PURE__*/function (_BaseCalculator) {
|
|
16
|
+
_inherits(CompletenessCalculator, _BaseCalculator);
|
|
17
|
+
var _super = _createSuper(CompletenessCalculator);
|
|
18
|
+
function CompletenessCalculator(_ref) {
|
|
19
|
+
var value = _ref.value,
|
|
20
|
+
statisticThreadManager = _ref.statisticThreadManager,
|
|
21
|
+
username = _ref.username,
|
|
22
|
+
userId = _ref.userId;
|
|
23
|
+
_classCallCheck(this, CompletenessCalculator);
|
|
24
|
+
return _super.call(this, {
|
|
25
|
+
value: value,
|
|
26
|
+
statisticThreadManager: statisticThreadManager,
|
|
27
|
+
username: username,
|
|
28
|
+
userId: userId
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
_createClass(CompletenessCalculator, [{
|
|
32
|
+
key: "isValidChart",
|
|
33
|
+
value: function isValidChart(chart) {
|
|
34
|
+
if (!this.validateBaseConfigs(chart)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
var type = chart.type,
|
|
38
|
+
table_id = chart.table_id,
|
|
39
|
+
name_column = chart.name_column,
|
|
40
|
+
completed_column = chart.completed_column,
|
|
41
|
+
target_column = chart.target_column,
|
|
42
|
+
group_column = chart.group_column;
|
|
43
|
+
var table = this.getTableById(table_id);
|
|
44
|
+
if (!TableUtils.getTableColumnByKey(table, name_column)) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
if (!TableUtils.getTableColumnByKey(table, completed_column)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (!TableUtils.getTableColumnByKey(table, target_column)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (type === STAT_TYPE.GROUP_COMPLETENESS_CHART && (!group_column || !TableUtils.getTableColumnByKey(table, group_column))) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "calculate",
|
|
60
|
+
value: function () {
|
|
61
|
+
var _calculate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(chart) {
|
|
62
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
63
|
+
while (1) {
|
|
64
|
+
switch (_context.prev = _context.next) {
|
|
65
|
+
case 0:
|
|
66
|
+
if (this.isValidChart(chart)) {
|
|
67
|
+
_context.next = 2;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
return _context.abrupt("return", []);
|
|
71
|
+
case 2:
|
|
72
|
+
if (!this.isCalcByQueryDB(chart)) {
|
|
73
|
+
_context.next = 6;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
_context.next = 5;
|
|
77
|
+
return this.queryDb(chart);
|
|
78
|
+
case 5:
|
|
79
|
+
return _context.abrupt("return", _context.sent);
|
|
80
|
+
case 6:
|
|
81
|
+
_context.next = 8;
|
|
82
|
+
return this.calculateWithWorker(chart);
|
|
83
|
+
case 8:
|
|
84
|
+
return _context.abrupt("return", _context.sent);
|
|
85
|
+
case 9:
|
|
86
|
+
case "end":
|
|
87
|
+
return _context.stop();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, _callee, this);
|
|
91
|
+
}));
|
|
92
|
+
function calculate(_x) {
|
|
93
|
+
return _calculate.apply(this, arguments);
|
|
94
|
+
}
|
|
95
|
+
return calculate;
|
|
96
|
+
}()
|
|
97
|
+
}, {
|
|
98
|
+
key: "queryDb",
|
|
99
|
+
value: function () {
|
|
100
|
+
var _queryDb = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(chart) {
|
|
101
|
+
var _this = this;
|
|
102
|
+
var table_id, view_id, name_column, completed_column, target_column, group_column, date_granularity, selectedTable, selectedView, selectedColumn, groupName, sqlCondition, completedColumn, targetColumn, groupColumn, sqlOrder, isColumnDataAsAnArray, memo, resultList, completedColumnName, targetColumnName, sqlString, result, data, isTimeGroupColumn, isGroupColumnDataAsAnArray, _completedColumnName, _targetColumnName, groupColumnName, _sqlString, _result, colorMap, _data, colorIndex;
|
|
103
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
104
|
+
while (1) {
|
|
105
|
+
switch (_context2.prev = _context2.next) {
|
|
106
|
+
case 0:
|
|
107
|
+
table_id = chart.table_id, view_id = chart.view_id, name_column = chart.name_column, completed_column = chart.completed_column, target_column = chart.target_column, group_column = chart.group_column, date_granularity = chart.date_granularity;
|
|
108
|
+
selectedTable = this.getTableById(table_id);
|
|
109
|
+
selectedView = this.getViewById(view_id, selectedTable);
|
|
110
|
+
if (selectedView) {
|
|
111
|
+
_context2.next = 5;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
return _context2.abrupt("return", []);
|
|
115
|
+
case 5:
|
|
116
|
+
selectedColumn = TableUtils.getTableColumnByKey(selectedTable, name_column);
|
|
117
|
+
groupName = "`".concat(selectedColumn.name, "`");
|
|
118
|
+
sqlCondition = filter2SqlCondition(selectedTable, selectedView);
|
|
119
|
+
completedColumn = TableUtils.getTableColumnByKey(selectedTable, completed_column);
|
|
120
|
+
targetColumn = TableUtils.getTableColumnByKey(selectedTable, target_column);
|
|
121
|
+
groupColumn = TableUtils.getTableColumnByKey(selectedTable, group_column);
|
|
122
|
+
sqlOrder = getSqlOrder(null, groupName);
|
|
123
|
+
isColumnDataAsAnArray = isArrayCellValue(selectedColumn);
|
|
124
|
+
memo = new Map();
|
|
125
|
+
resultList = [];
|
|
126
|
+
if (groupColumn) {
|
|
127
|
+
_context2.next = 29;
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
completedColumnName = "`".concat(completedColumn.name, "`"), targetColumnName = "`".concat(targetColumn.name, "`");
|
|
131
|
+
sqlString = "select ".concat(groupName, ", ").concat(completedColumnName, ", ").concat(targetColumnName, " from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by ").concat(groupName, ", ").concat(completedColumnName, ", ").concat(targetColumnName, " ").concat(sqlOrder, " desc limit 5000");
|
|
132
|
+
_context2.next = 20;
|
|
133
|
+
return this.sqlQuery(sqlString);
|
|
134
|
+
case 20:
|
|
135
|
+
result = _context2.sent;
|
|
136
|
+
if (!(!result.status === 200 || !result.data.success)) {
|
|
137
|
+
_context2.next = 23;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
return _context2.abrupt("return", []);
|
|
141
|
+
case 23:
|
|
142
|
+
data = result.data;
|
|
143
|
+
if (data.results) {
|
|
144
|
+
_context2.next = 26;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
return _context2.abrupt("return", []);
|
|
148
|
+
case 26:
|
|
149
|
+
data.results.forEach(function (item) {
|
|
150
|
+
var name = item[selectedColumn.key];
|
|
151
|
+
var label;
|
|
152
|
+
if (name || Number.isFinite(name)) {
|
|
153
|
+
label = StatUtils.getGroupLabel(name, {}, selectedColumn, '', '', _this.value);
|
|
154
|
+
if (isColumnDataAsAnArray) {
|
|
155
|
+
label = label[0];
|
|
156
|
+
}
|
|
157
|
+
label = getFormattedLabel(selectedColumn, label, _this.value.collaborators);
|
|
158
|
+
if (!memo.get(label)) {
|
|
159
|
+
var completedValue = item[completedColumn.key] || 0;
|
|
160
|
+
var targetValue = item[targetColumn.key] || 0;
|
|
161
|
+
if (completedValue >= targetValue) {
|
|
162
|
+
resultList.push({
|
|
163
|
+
name: label,
|
|
164
|
+
original_name: name,
|
|
165
|
+
value: completedValue,
|
|
166
|
+
type: 'completed',
|
|
167
|
+
current_value: completedValue,
|
|
168
|
+
target_value: targetValue
|
|
169
|
+
});
|
|
170
|
+
} else {
|
|
171
|
+
resultList.push({
|
|
172
|
+
name: label,
|
|
173
|
+
original_name: name,
|
|
174
|
+
value: completedValue,
|
|
175
|
+
type: 'completed',
|
|
176
|
+
current_value: completedValue,
|
|
177
|
+
target_value: targetValue
|
|
178
|
+
}, {
|
|
179
|
+
name: label,
|
|
180
|
+
original_name: name,
|
|
181
|
+
value: targetValue - completedValue,
|
|
182
|
+
type: 'uncompleted',
|
|
183
|
+
current_value: completedValue,
|
|
184
|
+
target_value: targetValue
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
memo.set(label, 1);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
_context2.next = 48;
|
|
192
|
+
break;
|
|
193
|
+
case 29:
|
|
194
|
+
isTimeGroupColumn = TIME_COLUMN_LIST.includes(groupColumn.type);
|
|
195
|
+
isGroupColumnDataAsAnArray = isArrayCellValue(groupColumn);
|
|
196
|
+
_completedColumnName = "`".concat(completedColumn.name, "`");
|
|
197
|
+
_targetColumnName = "`".concat(targetColumn.name, "`");
|
|
198
|
+
groupColumnName = "`".concat(groupColumn.name, "`");
|
|
199
|
+
if (isTimeGroupColumn) {
|
|
200
|
+
groupColumnName = getSqlGroup(date_granularity, groupColumn);
|
|
201
|
+
}
|
|
202
|
+
_sqlString = "select ".concat(groupName, ", ").concat(_completedColumnName, ", ").concat(_targetColumnName, ", ").concat(groupColumnName, " from `").concat(selectedTable.name, "` ").concat(sqlCondition, " group by ").concat(groupName, ", ").concat(_completedColumnName, ", ").concat(_targetColumnName, ", ").concat(groupColumnName, " ").concat(sqlOrder, " desc limit 5000");
|
|
203
|
+
_context2.next = 38;
|
|
204
|
+
return this.sqlQuery(_sqlString);
|
|
205
|
+
case 38:
|
|
206
|
+
_result = _context2.sent;
|
|
207
|
+
colorMap = {};
|
|
208
|
+
if (!(!_result.status === 200 || !_result.data.success)) {
|
|
209
|
+
_context2.next = 42;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
return _context2.abrupt("return", []);
|
|
213
|
+
case 42:
|
|
214
|
+
_data = _result.data;
|
|
215
|
+
if (_data.results) {
|
|
216
|
+
_context2.next = 45;
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
return _context2.abrupt("return", []);
|
|
220
|
+
case 45:
|
|
221
|
+
colorIndex = 0;
|
|
222
|
+
_data.results.forEach(function (item) {
|
|
223
|
+
var name = item[selectedColumn.key];
|
|
224
|
+
var label;
|
|
225
|
+
var groupLabel;
|
|
226
|
+
|
|
227
|
+
// get and format name
|
|
228
|
+
if (name || Number.isFinite(name)) {
|
|
229
|
+
label = StatUtils.getGroupLabel(name, {}, selectedColumn, '', '', _this.value);
|
|
230
|
+
if (isColumnDataAsAnArray) {
|
|
231
|
+
label = label[0];
|
|
232
|
+
}
|
|
233
|
+
label = getFormattedLabel(selectedColumn, label, _this.value.collaborators);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// get and format group name
|
|
237
|
+
if (!isTimeGroupColumn) {
|
|
238
|
+
groupLabel = item[groupColumn.key];
|
|
239
|
+
groupLabel = StatUtils.getGroupLabel(groupLabel, {}, groupColumn, '', '', _this.value);
|
|
240
|
+
if (groupLabel && isGroupColumnDataAsAnArray) {
|
|
241
|
+
groupLabel = groupLabel[0];
|
|
242
|
+
}
|
|
243
|
+
groupLabel = getFormattedLabel(groupColumn, groupLabel, _this.value.collaborators);
|
|
244
|
+
} else {
|
|
245
|
+
groupLabel = item[groupColumnName] + '';
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// get group color
|
|
249
|
+
var color = colorMap[groupLabel];
|
|
250
|
+
if (!color) {
|
|
251
|
+
color = PIE_CHART_COLORS[colorIndex % 12];
|
|
252
|
+
colorMap[groupLabel] = color;
|
|
253
|
+
colorIndex++;
|
|
254
|
+
}
|
|
255
|
+
var cache = memo.get(label);
|
|
256
|
+
if (!cache || !cache[groupLabel]) {
|
|
257
|
+
var completedValue = item[completedColumn.key] || 0;
|
|
258
|
+
var targetValue = item[targetColumn.key] || 0;
|
|
259
|
+
if (label && groupLabel) {
|
|
260
|
+
resultList.push({
|
|
261
|
+
name: label,
|
|
262
|
+
original_name: name,
|
|
263
|
+
group_label: groupLabel,
|
|
264
|
+
value: completedValue,
|
|
265
|
+
type: 'completed',
|
|
266
|
+
current_value: completedValue,
|
|
267
|
+
target_value: targetValue
|
|
268
|
+
});
|
|
269
|
+
if (completedValue < targetValue) {
|
|
270
|
+
resultList.push({
|
|
271
|
+
name: label,
|
|
272
|
+
original_name: name,
|
|
273
|
+
group_label: groupLabel,
|
|
274
|
+
value: targetValue - completedValue,
|
|
275
|
+
type: 'uncompleted',
|
|
276
|
+
current_value: completedValue,
|
|
277
|
+
target_value: targetValue
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
if (cache) {
|
|
281
|
+
cache[groupLabel] = 1;
|
|
282
|
+
memo.set(label, cache);
|
|
283
|
+
} else {
|
|
284
|
+
memo.set(label, _defineProperty({}, groupLabel, 1));
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
resultList.colorMap = colorMap;
|
|
290
|
+
case 48:
|
|
291
|
+
return _context2.abrupt("return", resultList);
|
|
292
|
+
case 49:
|
|
293
|
+
case "end":
|
|
294
|
+
return _context2.stop();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}, _callee2, this);
|
|
298
|
+
}));
|
|
299
|
+
function queryDb(_x2) {
|
|
300
|
+
return _queryDb.apply(this, arguments);
|
|
301
|
+
}
|
|
302
|
+
return queryDb;
|
|
303
|
+
}()
|
|
304
|
+
}]);
|
|
305
|
+
return CompletenessCalculator;
|
|
306
|
+
}(BaseCalculator);
|
|
307
|
+
export default CompletenessCalculator;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var IGNORE_KEYS = ['description', 'format_version', 'plugin_settings', 'plugins', 'statistics', 'version', 'scripts', 'settings'];
|
|
2
|
+
var TABLE_IGNORE_KEYS = ['summary_configs', 'is_header_locked'];
|
|
3
|
+
var copyValue = function copyValue(value) {
|
|
4
|
+
var newValue = {};
|
|
5
|
+
Object.keys(value).forEach(function (key) {
|
|
6
|
+
if (key !== 'tables' && !IGNORE_KEYS.includes(key)) {
|
|
7
|
+
newValue[key] = value[key];
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
var tables = value.tables;
|
|
11
|
+
var newTables = [];
|
|
12
|
+
tables.forEach(function (table) {
|
|
13
|
+
var newTable = {};
|
|
14
|
+
Object.keys(table).forEach(function (key) {
|
|
15
|
+
if (key === 'columns') {
|
|
16
|
+
var columns = table.columns;
|
|
17
|
+
var newColumns = [];
|
|
18
|
+
columns.forEach(function (column) {
|
|
19
|
+
var newColumn = Object.assign({}, column, {
|
|
20
|
+
editor: null,
|
|
21
|
+
formatter: null
|
|
22
|
+
});
|
|
23
|
+
newColumns.push(newColumn);
|
|
24
|
+
});
|
|
25
|
+
newTable.columns = newColumns;
|
|
26
|
+
} else if (key === 'views') {
|
|
27
|
+
var views = table['views'];
|
|
28
|
+
var newViews = [];
|
|
29
|
+
views.forEach(function (view) {
|
|
30
|
+
var newView = Object.assign({}, view, {
|
|
31
|
+
colorbys: null,
|
|
32
|
+
archived_columns: null,
|
|
33
|
+
archived_rows: null
|
|
34
|
+
});
|
|
35
|
+
newViews.push(newView);
|
|
36
|
+
});
|
|
37
|
+
newTable[key] = newViews;
|
|
38
|
+
} else if (!TABLE_IGNORE_KEYS.includes(key)) {
|
|
39
|
+
newTable[key] = table[key];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
newTables.push(newTable);
|
|
43
|
+
});
|
|
44
|
+
newValue.tables = newTables;
|
|
45
|
+
return newValue;
|
|
46
|
+
};
|
|
47
|
+
export default copyValue;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
7
|
+
import { filter2SqlCondition, TableUtils } from 'dtable-store';
|
|
8
|
+
import { DTABLE_DB_SUMMARY_METHOD } from '../constants';
|
|
9
|
+
import { getSummaryColumnMethod } from '../utils/common-utils';
|
|
10
|
+
import BaseCalculator from './base-calculator';
|
|
11
|
+
var DashboardCalculator = /*#__PURE__*/function (_BaseCalculator) {
|
|
12
|
+
_inherits(DashboardCalculator, _BaseCalculator);
|
|
13
|
+
var _super = _createSuper(DashboardCalculator);
|
|
14
|
+
function DashboardCalculator(_ref) {
|
|
15
|
+
var value = _ref.value,
|
|
16
|
+
statisticThreadManager = _ref.statisticThreadManager,
|
|
17
|
+
username = _ref.username,
|
|
18
|
+
userId = _ref.userId;
|
|
19
|
+
_classCallCheck(this, DashboardCalculator);
|
|
20
|
+
return _super.call(this, {
|
|
21
|
+
value: value,
|
|
22
|
+
statisticThreadManager: statisticThreadManager,
|
|
23
|
+
username: username,
|
|
24
|
+
userId: userId
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
_createClass(DashboardCalculator, [{
|
|
28
|
+
key: "isValidChart",
|
|
29
|
+
value: function isValidChart(chart) {
|
|
30
|
+
if (!this.validateBaseConfigs(chart)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
var table_id = chart.table_id,
|
|
34
|
+
target_value_column = chart.target_value_column,
|
|
35
|
+
total_value_column = chart.total_value_column;
|
|
36
|
+
var table = this.getTableById(table_id);
|
|
37
|
+
var selectedColumn1 = TableUtils.getTableColumnByKey(table, target_value_column);
|
|
38
|
+
var selectedColumn2 = TableUtils.getTableColumnByKey(table, total_value_column);
|
|
39
|
+
if (!selectedColumn1 || !selectedColumn2) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
key: "calculate",
|
|
46
|
+
value: function () {
|
|
47
|
+
var _calculate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(chart) {
|
|
48
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
49
|
+
while (1) {
|
|
50
|
+
switch (_context.prev = _context.next) {
|
|
51
|
+
case 0:
|
|
52
|
+
if (this.isValidChart(chart)) {
|
|
53
|
+
_context.next = 2;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
return _context.abrupt("return", 0);
|
|
57
|
+
case 2:
|
|
58
|
+
if (!this.isCalcByQueryDB(chart)) {
|
|
59
|
+
_context.next = 6;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
_context.next = 5;
|
|
63
|
+
return this.queryDb(chart);
|
|
64
|
+
case 5:
|
|
65
|
+
return _context.abrupt("return", _context.sent);
|
|
66
|
+
case 6:
|
|
67
|
+
_context.next = 8;
|
|
68
|
+
return this.calculateWithWorker(chart);
|
|
69
|
+
case 8:
|
|
70
|
+
return _context.abrupt("return", _context.sent);
|
|
71
|
+
case 9:
|
|
72
|
+
case "end":
|
|
73
|
+
return _context.stop();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}, _callee, this);
|
|
77
|
+
}));
|
|
78
|
+
function calculate(_x) {
|
|
79
|
+
return _calculate.apply(this, arguments);
|
|
80
|
+
}
|
|
81
|
+
return calculate;
|
|
82
|
+
}()
|
|
83
|
+
}, {
|
|
84
|
+
key: "queryDb",
|
|
85
|
+
value: function () {
|
|
86
|
+
var _queryDb = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(chart) {
|
|
87
|
+
var table_id, view_id, target_value_column, target_value_column_summary_method, total_value_column, total_value_column_summary_method, selectedTable, selectedView, selectedColumn1, selectedColumn2, sqlCondition, key1, key2, sqlString, result, data, result1, result2;
|
|
88
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
89
|
+
while (1) {
|
|
90
|
+
switch (_context2.prev = _context2.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
table_id = chart.table_id, view_id = chart.view_id, target_value_column = chart.target_value_column, target_value_column_summary_method = chart.target_value_column_summary_method, total_value_column = chart.total_value_column, total_value_column_summary_method = chart.total_value_column_summary_method;
|
|
93
|
+
selectedTable = this.getTableById(table_id);
|
|
94
|
+
selectedView = this.getViewById(view_id, selectedTable);
|
|
95
|
+
selectedColumn1 = TableUtils.getTableColumnByKey(selectedTable, target_value_column);
|
|
96
|
+
selectedColumn2 = TableUtils.getTableColumnByKey(selectedTable, total_value_column);
|
|
97
|
+
sqlCondition = filter2SqlCondition(selectedTable, selectedView);
|
|
98
|
+
key1 = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[target_value_column_summary_method], selectedColumn1.name);
|
|
99
|
+
key2 = getSummaryColumnMethod(DTABLE_DB_SUMMARY_METHOD[total_value_column_summary_method], selectedColumn2.name);
|
|
100
|
+
sqlString = "select ".concat(key1, ", ").concat(key2, " from `").concat(selectedTable.name, "` ").concat(sqlCondition, " limit 5000");
|
|
101
|
+
_context2.next = 11;
|
|
102
|
+
return this.sqlQuery(sqlString);
|
|
103
|
+
case 11:
|
|
104
|
+
result = _context2.sent;
|
|
105
|
+
if (!(result.status === 200 && result.data.success)) {
|
|
106
|
+
_context2.next = 22;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
data = result.data.results;
|
|
110
|
+
if (data) {
|
|
111
|
+
_context2.next = 16;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
return _context2.abrupt("return", 0);
|
|
115
|
+
case 16:
|
|
116
|
+
if (!(data.length > 0)) {
|
|
117
|
+
_context2.next = 22;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
result1 = data[0][key1];
|
|
121
|
+
result2 = data[0][key2];
|
|
122
|
+
if (!(result2 === 0)) {
|
|
123
|
+
_context2.next = 21;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
return _context2.abrupt("return", 0);
|
|
127
|
+
case 21:
|
|
128
|
+
return _context2.abrupt("return", result1 / result2);
|
|
129
|
+
case 22:
|
|
130
|
+
return _context2.abrupt("return", 0);
|
|
131
|
+
case 23:
|
|
132
|
+
case "end":
|
|
133
|
+
return _context2.stop();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}, _callee2, this);
|
|
137
|
+
}));
|
|
138
|
+
function queryDb(_x2) {
|
|
139
|
+
return _queryDb.apply(this, arguments);
|
|
140
|
+
}
|
|
141
|
+
return queryDb;
|
|
142
|
+
}()
|
|
143
|
+
}]);
|
|
144
|
+
return DashboardCalculator;
|
|
145
|
+
}(BaseCalculator);
|
|
146
|
+
export default DashboardCalculator;
|