dtable-statistic 5.0.48-alpha.0 → 5.0.48-alpha.1

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 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
- return _dtableStore.Views.optimizedGetViewRows(view, table, dtableStore.value, username, userId, userDepartmentIdsMap);
44
+ const rows = await (0, _calcWithWorker.calcViewRowsWithWorker)(view, table, this.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
- return _dtableStore.Views.getTableFormulaResultsWithWroker(table, rows, dtableStore.value, formulaColumns, {
54
- username,
55
- userId,
56
- userDepartmentIdsMap
57
- });
55
+ const res = await (0, _calcWithWorker.calcFormulaResultsWithWorker)(table, rows, this.dtableStore.value, formulaColumns, username, userId, userDepartmentIdsMap);
56
+ return res;
58
57
  }
59
58
  static updateStatistics(dtableStore, statistics) {
60
59
  dtableStore.updateStatisticsList(statistics);
@@ -48,27 +48,4 @@ function calcFormulaResultsWithWorker(table, rows, value, formulaColumns, userna
48
48
  worker.terminate();
49
49
  };
50
50
  });
51
- }
52
-
53
- // export async function calcWithWorker(view, table, value) {
54
- // let res = [];
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
- // }
51
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "5.0.48-alpha.0",
3
+ "version": "5.0.48-alpha.1",
4
4
  "description": "statistics",
5
5
  "main": "dist/dtable-statistic.js",
6
6
  "author": "seafile",