@ejfdelgado/ejflab-common 1.13.3 → 1.14.0

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ejfdelgado/ejflab-common",
3
3
  "type": "commonjs",
4
- "version": "1.13.3",
4
+ "version": "1.14.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/ejfdelgado/ejflab-common.git"
package/src/MyDates.js CHANGED
@@ -1,5 +1,7 @@
1
1
  const offset = new Date().getTimezoneOffset() / 60;
2
2
 
3
+ // https://www.npmjs.com/package/dateformat
4
+
3
5
  class MyDates {
4
6
  static getSelectedLanguage() {
5
7
  const urlParams = new URLSearchParams(window.location.search);
@@ -138,16 +140,15 @@ class MyDates {
138
140
  }
139
141
  // MyDates.getDefaults(args)
140
142
  static getDefaults(args, currentYear, nextYears, myDefault = "") {
141
- console.log(JSON.stringify(args, null, 4));
142
143
  if (args instanceof Array) {
143
- if (args.lenght == 1) {
144
+ if (args.length == 1) {
144
145
  currentYear = args[0];
145
146
  nextYears = args[0];
146
- } else if (args.lenght == 2) {
147
+ } else if (args.length == 2) {
147
148
  currentYear = args[0];
148
149
  nextYears = args[1];
149
150
  }
150
- if (args.lenght >= 3) {
151
+ if (args.length >= 3) {
151
152
  myDefault = args[2];
152
153
  }
153
154
  }
@@ -10,7 +10,8 @@ class CommandPostgres extends CommandBasic {
10
10
  const script = this.args[3];
11
11
  const destination = this.args[4];
12
12
  const postgresSrv = this.context.getSuperContext().getPostgresClient();
13
- if (action == "execute") {
13
+ const paging = action == "page";
14
+ if (["execute", "page"].indexOf(action) >= 0) {
14
15
  //console.log("Starting execute...");
15
16
  const dbIdData = SimpleObj.getValue(this.context.data, dbIdPath, null);
16
17
  let bodyData = {};
@@ -35,7 +36,21 @@ class CommandPostgres extends CommandBasic {
35
36
  const payload = JSON.parse(JSON.stringify(dbIdData));
36
37
  payload.object = bodyData[i];
37
38
  payload.now = now;
38
- const result = await postgresSrv.executeFile(script, payload, client);
39
+ const result = { rows: [], rowCount: 0, command: null };
40
+ let localResult = { rows: [], rowCount: 0, command: null };
41
+ if (paging) {
42
+ if (typeof payload.limit !== "number") {
43
+ payload.limit = 20;
44
+ }
45
+ payload.offset = 0;
46
+ }
47
+ do {
48
+ localResult = await postgresSrv.executeFile(script, payload, client);
49
+ result.rows.push(...localResult.rows);
50
+ result.rowCount += localResult.rowCount;
51
+ result.command = localResult.command;
52
+ payload.offset += result.rows.length;
53
+ } while (paging && localResult.rows.length > 0);
39
54
  response.push(result);
40
55
  }
41
56
  await client.query("COMMIT");