@xuda.io/xuda-worker-bundle 1.3.2529 → 1.3.2531
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/index.js +30 -30
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -2031,6 +2031,36 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
|
|
|
2031
2031
|
_dataSourceFilterModelType,
|
|
2032
2032
|
);
|
|
2033
2033
|
|
|
2034
|
+
if (_dataSourceFilterModelType === 'index' && _ds?.progDataSource?.sortModel) {
|
|
2035
|
+
function sortByKeys(array, sortConfig) {
|
|
2036
|
+
return array.sort((a, b) => {
|
|
2037
|
+
for (let config of sortConfig) {
|
|
2038
|
+
const key = config.field_id;
|
|
2039
|
+
const direction = config.sort_dir === 'desc' ? -1 : 1;
|
|
2040
|
+
|
|
2041
|
+
const valA = a.value[key];
|
|
2042
|
+
const valB = b.value[key];
|
|
2043
|
+
|
|
2044
|
+
// Handle numeric comparison
|
|
2045
|
+
if (typeof valA === 'number' && typeof valB === 'number') {
|
|
2046
|
+
if (valA !== valB) {
|
|
2047
|
+
return (valA - valB) * direction;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
// Handle string comparison
|
|
2051
|
+
else if (typeof valA === 'string' && typeof valB === 'string') {
|
|
2052
|
+
if (valA !== valB) {
|
|
2053
|
+
return valA.localeCompare(valB) * direction;
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
return 0;
|
|
2058
|
+
});
|
|
2059
|
+
}
|
|
2060
|
+
const sorted = sortByKeys(_ds.v.raw_data.rows, _ds.progDataSource.sortModel);
|
|
2061
|
+
_ds.v.raw_data.rows = sorted;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2034
2064
|
if (_ds?.progDataSource?.dataSourceLimit) {
|
|
2035
2065
|
const ret_rows_found = await func.db.get_query(SESSION_ID, _ds._dataSourceTableId, _ds.v.couchView, dataSourceSession, _ds.viewSourceDesc, 'datasource table', prog_obj.progDataSource.dataSourceReduce, null, null, true, null, null, null, filterModel, _dataSourceFilterModelType);
|
|
2036
2066
|
_ds.rows_found = ret_rows_found?.rows?.[0]?.value || 0;
|
|
@@ -2049,17 +2079,8 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
|
|
|
2049
2079
|
data = [];
|
|
2050
2080
|
}
|
|
2051
2081
|
|
|
2052
|
-
// let _KEY = 0;
|
|
2053
|
-
// for (const _VAL of data) {
|
|
2054
|
-
// _ds.data_feed.rows[_KEY] = { _KEY, _VAL };
|
|
2055
|
-
// _KEY++;
|
|
2056
|
-
// }
|
|
2057
|
-
|
|
2058
2082
|
_ds.rows_found = data?.length || 0;
|
|
2059
2083
|
|
|
2060
|
-
// if (!_ds.v.raw_data) {
|
|
2061
|
-
// _ds.v.raw_data = { rows: [] };
|
|
2062
|
-
// }
|
|
2063
2084
|
let _KEY = 0;
|
|
2064
2085
|
for (const _VAL of data) {
|
|
2065
2086
|
_ds.v.raw_data.rows.push({ id: _KEY, value: { _KEY, _VAL } });
|
|
@@ -2074,13 +2095,7 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
|
|
|
2074
2095
|
data = {};
|
|
2075
2096
|
}
|
|
2076
2097
|
|
|
2077
|
-
// for (let [_KEY, _VAL] of Object.keys(data)) {
|
|
2078
|
-
// _ds.data_feed.rows[_KEY] = { _KEY, _VAL };
|
|
2079
|
-
// }
|
|
2080
2098
|
_ds.rows_found = Object.keys(data)?.length || 0;
|
|
2081
|
-
// if (!_ds.v.raw_data) {
|
|
2082
|
-
// _ds.v.raw_data = { rows: [] };
|
|
2083
|
-
// }
|
|
2084
2099
|
|
|
2085
2100
|
for (let [_KEY, _VAL] of Object.keys(data)) {
|
|
2086
2101
|
_ds.v.raw_data.rows.push({ id: _KEY, value: { _KEY, _VAL } });
|
|
@@ -2095,21 +2110,6 @@ func.datasource.execute = async function (SESSION_ID, dataSourceSession, IS_DATA
|
|
|
2095
2110
|
data = '';
|
|
2096
2111
|
}
|
|
2097
2112
|
|
|
2098
|
-
// if (!_ds.v.raw_data) {
|
|
2099
|
-
// _ds.v.raw_data = { rows: [] };
|
|
2100
|
-
// }
|
|
2101
|
-
|
|
2102
|
-
// let _KEY = 0;
|
|
2103
|
-
// let arr = data.split(",");
|
|
2104
|
-
// for (const _VAL of arr) {
|
|
2105
|
-
// _ds.data_feed.rows[_KEY] = { _KEY, _VAL };
|
|
2106
|
-
// _KEY++;
|
|
2107
|
-
// }
|
|
2108
|
-
// _ds.rows_found = arr?.length || 0;
|
|
2109
|
-
// if (!_ds.v.raw_data) {
|
|
2110
|
-
// _ds.v.raw_data = { rows: [] };
|
|
2111
|
-
// }
|
|
2112
|
-
|
|
2113
2113
|
let _KEY = 0;
|
|
2114
2114
|
let arr = data.split(',');
|
|
2115
2115
|
for (const _VAL of arr) {
|