dtable-statistic 5.0.48-alpha.0 → 5.0.48-alpha.10
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/es/index.js +7 -8
- package/es/utils/formula-calc-worker/calc-formula-result.worker.js +10 -0
- package/es/utils/formula-calc-worker/calc-view-rows.worker.js +10 -0
- package/es/utils/formula-calc-worker/calc-with-worker.js +23 -65
- package/es/utils/formula-calc-worker/calc.worker.js +8 -0
- package/package.json +3 -4
- package/es/utils/formula-calc-worker/calc-formula-result-worker.js +0 -21
- package/es/utils/formula-calc-worker/calc-view-rows-worker.js +0 -16
package/es/index.js
CHANGED
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
var _react = _interopRequireDefault(require("react"));
|
|
5
5
|
var _dtableStore = require("dtable-store");
|
|
6
6
|
var _dashboard = _interopRequireDefault(require("./dashboard"));
|
|
7
|
+
var _calcWithWorker = require("./utils/formula-calc-worker/calc-with-worker");
|
|
7
8
|
class Statistic {
|
|
8
9
|
static getInitProps() {
|
|
9
10
|
if (!window || !window.app) {
|
|
@@ -33,16 +34,17 @@ class Statistic {
|
|
|
33
34
|
deletePluginSettings: this.deletePluginSettings.bind(this, dtableStore)
|
|
34
35
|
};
|
|
35
36
|
}
|
|
36
|
-
static getViewRows(view, table) {
|
|
37
|
+
static async getViewRows(view, table) {
|
|
37
38
|
const dtableStore = window.app.dtableStore || {};
|
|
38
39
|
const {
|
|
39
40
|
username = null,
|
|
40
41
|
userId = null,
|
|
41
42
|
userDepartmentIdsMap = null
|
|
42
43
|
} = dtableStore.dtableSettings;
|
|
43
|
-
|
|
44
|
+
const rows = await (0, _calcWithWorker.calcViewRowsWithWorker)(view, table, dtableStore.value, username, userId, userDepartmentIdsMap);
|
|
45
|
+
return rows;
|
|
44
46
|
}
|
|
45
|
-
static getTableFormulaResults(table, rows) {
|
|
47
|
+
static async getTableFormulaResults(table, rows) {
|
|
46
48
|
const dtableStore = window.app.dtableStore || {};
|
|
47
49
|
const {
|
|
48
50
|
username = null,
|
|
@@ -50,11 +52,8 @@ class Statistic {
|
|
|
50
52
|
userDepartmentIdsMap = null
|
|
51
53
|
} = dtableStore.dtableSettings;
|
|
52
54
|
const formulaColumns = _dtableStore.Views.getFormulaColumnsContainLinks(table);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
userId,
|
|
56
|
-
userDepartmentIdsMap
|
|
57
|
-
});
|
|
55
|
+
const res = await (0, _calcWithWorker.calcFormulaResultsWithWorker)(table, rows, dtableStore.value, formulaColumns, username, userId, userDepartmentIdsMap);
|
|
56
|
+
return res;
|
|
58
57
|
}
|
|
59
58
|
static updateStatistics(dtableStore, statistics) {
|
|
60
59
|
dtableStore.updateStatisticsList(statistics);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var Comlink = _interopRequireWildcard(require("comlink"));
|
|
5
|
+
async function calcFormulaResults(callback) {
|
|
6
|
+
// const res = Views.getTableFormulaResults(table, rows, value, formulaColumns, { username, userId, userDepartmentIdsMap });
|
|
7
|
+
const res = await callback();
|
|
8
|
+
return res;
|
|
9
|
+
}
|
|
10
|
+
Comlink.expose(calcFormulaResults);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
+
var Comlink = _interopRequireWildcard(require("comlink"));
|
|
5
|
+
async function calcViewRows(callback) {
|
|
6
|
+
// const rows = Views.getViewRows(view, table, value, username, userId, userDepartmentIdsMap);
|
|
7
|
+
const rows = await callback();
|
|
8
|
+
return rows;
|
|
9
|
+
}
|
|
10
|
+
Comlink.expose(calcViewRows);
|
|
@@ -1,74 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.calcFormulaResultsWithWorker = calcFormulaResultsWithWorker;
|
|
7
9
|
exports.calcViewRowsWithWorker = calcViewRowsWithWorker;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
worker.onmessage = function (e) {
|
|
19
|
-
resolve(e.data);
|
|
20
|
-
worker.terminate();
|
|
21
|
-
};
|
|
22
|
-
worker.onerror = function (e) {
|
|
23
|
-
reject(e);
|
|
24
|
-
worker.terminate();
|
|
25
|
-
};
|
|
26
|
-
});
|
|
10
|
+
var Comlink = _interopRequireWildcard(require("comlink"));
|
|
11
|
+
var _calc = _interopRequireDefault(require("./calc.worker"));
|
|
12
|
+
var _dtableStore = require("dtable-store");
|
|
13
|
+
async function calcViewRowsWithWorker(view, table, value, username, userId, userDepartmentIdsMap) {
|
|
14
|
+
const worker = new _calc.default();
|
|
15
|
+
const calcWorker = Comlink.wrap(worker);
|
|
16
|
+
const cb = () => _dtableStore.Views.getViewRows(view, table, value, username, userId, userDepartmentIdsMap);
|
|
17
|
+
const rows = await calcWorker(Comlink.proxy(cb));
|
|
18
|
+
worker.terminate();
|
|
19
|
+
return rows;
|
|
27
20
|
}
|
|
28
|
-
function calcFormulaResultsWithWorker(table, rows, value, formulaColumns, username, userId, userDepartmentIdsMap) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
rows,
|
|
36
|
-
value,
|
|
37
|
-
formulaColumns,
|
|
38
|
-
username,
|
|
39
|
-
userId,
|
|
40
|
-
userDepartmentIdsMap
|
|
41
|
-
});
|
|
42
|
-
worker.onmessage = function (e) {
|
|
43
|
-
resolve(e.data);
|
|
44
|
-
worker.terminate();
|
|
45
|
-
};
|
|
46
|
-
worker.onerror = function (e) {
|
|
47
|
-
reject(e);
|
|
48
|
-
worker.terminate();
|
|
49
|
-
};
|
|
21
|
+
async function calcFormulaResultsWithWorker(table, rows, value, formulaColumns, username, userId, userDepartmentIdsMap) {
|
|
22
|
+
const worker = new _calc.default();
|
|
23
|
+
const calcWorker = Comlink.wrap(worker);
|
|
24
|
+
const cb = () => _dtableStore.Views.getTableFormulaResults(table, rows, value, formulaColumns, {
|
|
25
|
+
username,
|
|
26
|
+
userId,
|
|
27
|
+
userDepartmentIdsMap
|
|
50
28
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// // set worker to 2
|
|
56
|
-
// const maxWorkers = 2;
|
|
57
|
-
// const numWorkers = Math.min(rows.length, maxWorkers);
|
|
58
|
-
// const sliceLength = Math.ceil(rows.length / numWorkers);
|
|
59
|
-
|
|
60
|
-
// let tasks = [];
|
|
61
|
-
// for (let i = 0; i < numWorkers; i++) {
|
|
62
|
-
// const start = i * sliceLength;
|
|
63
|
-
// const end = Math.min(start + sliceLength, rows.length);
|
|
64
|
-
// tasks.push(createWorker(columns, key_column_map, rows.slice(start, end), updatedFormulaRows, formulaCalculatorParams));
|
|
65
|
-
// }
|
|
66
|
-
|
|
67
|
-
// try {
|
|
68
|
-
// res = await Promise.all(tasks);
|
|
69
|
-
// } catch (error) {
|
|
70
|
-
// console.error('Error occurred', error);
|
|
71
|
-
// }
|
|
72
|
-
|
|
73
|
-
// return res;
|
|
74
|
-
// }
|
|
29
|
+
const results = await calcWorker(Comlink.proxy(cb));
|
|
30
|
+
worker.terminate();
|
|
31
|
+
return results;
|
|
32
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtable-statistic",
|
|
3
|
-
"version": "5.0.48-alpha.
|
|
3
|
+
"version": "5.0.48-alpha.10",
|
|
4
4
|
"description": "statistics",
|
|
5
5
|
"main": "dist/dtable-statistic.js",
|
|
6
6
|
"author": "seafile",
|
|
@@ -18,8 +18,7 @@
|
|
|
18
18
|
"react-grid-layout": "^1.2.5",
|
|
19
19
|
"react-intl-universal": "^2.4.8",
|
|
20
20
|
"reactstrap": "8.9.0",
|
|
21
|
-
"sea-chart": "
|
|
22
|
-
|
|
21
|
+
"sea-chart": "^0.0.95-alpha.4"
|
|
23
22
|
},
|
|
24
23
|
"peerDependencies": {
|
|
25
24
|
"dtable-ui-component": "~5.0.*",
|
|
@@ -53,7 +52,7 @@
|
|
|
53
52
|
"css-minimizer-webpack-plugin": "^3.2.0",
|
|
54
53
|
"dotenv": "^10.0.0",
|
|
55
54
|
"dotenv-expand": "^5.1.0",
|
|
56
|
-
"dtable-store": "
|
|
55
|
+
"dtable-store": "4.3.6",
|
|
57
56
|
"dtable-ui-component": "~5.0.11",
|
|
58
57
|
"dtable-utils": "5.0.0",
|
|
59
58
|
"dtable-web-api": "^5.0.3",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _dtableStore = require("dtable-store");
|
|
4
|
-
/* eslint-disable no-restricted-globals */
|
|
5
|
-
self.onmessage = function (e) {
|
|
6
|
-
const {
|
|
7
|
-
table,
|
|
8
|
-
rows,
|
|
9
|
-
value,
|
|
10
|
-
formulaColumns,
|
|
11
|
-
username,
|
|
12
|
-
userId,
|
|
13
|
-
userDepartmentIdsMap
|
|
14
|
-
} = e.data;
|
|
15
|
-
const res = _dtableStore.Views.getTableFormulaResults(table, rows, value, formulaColumns, {
|
|
16
|
-
username,
|
|
17
|
-
userId,
|
|
18
|
-
userDepartmentIdsMap
|
|
19
|
-
});
|
|
20
|
-
self.postMessage(res);
|
|
21
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _dtableStore = require("dtable-store");
|
|
4
|
-
/* eslint-disable no-restricted-globals */
|
|
5
|
-
self.onmessage = function (e) {
|
|
6
|
-
const {
|
|
7
|
-
view,
|
|
8
|
-
table,
|
|
9
|
-
value,
|
|
10
|
-
username,
|
|
11
|
-
userId,
|
|
12
|
-
userDepartmentIdsMap
|
|
13
|
-
} = e.data;
|
|
14
|
-
const rows = _dtableStore.Views.getViewRows(view, table, value, username, userId, userDepartmentIdsMap);
|
|
15
|
-
self.postMessage(rows);
|
|
16
|
-
};
|