ismx-nexo-node-app 0.4.136 → 0.4.138
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/dist/js/business/utils/DateUtils.js +27 -0
- package/dist/js/repository/RepositoryDatabasePostgres.js +12 -5
- package/dist/types/business/utils/DateUtils.d.ts +1 -0
- package/package.json +1 -1
- package/src/main/node/business/utils/DateUtils.ts +33 -0
- package/src/main/node/repository/RepositoryDatabasePostgres.ts +16 -4
|
@@ -91,6 +91,33 @@ class DateUtils {
|
|
|
91
91
|
};
|
|
92
92
|
return recursivelyRevive(obj);
|
|
93
93
|
}
|
|
94
|
+
static split(span, from, to) {
|
|
95
|
+
const dates = [];
|
|
96
|
+
const current = new Date(from);
|
|
97
|
+
switch (span) {
|
|
98
|
+
case 'day':
|
|
99
|
+
while (current <= to) {
|
|
100
|
+
dates.push(new Date(current));
|
|
101
|
+
current.setDate(current.getDate() + 1);
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
case 'month':
|
|
105
|
+
current.setDate(1);
|
|
106
|
+
while (current <= to) {
|
|
107
|
+
dates.push(new Date(current.getFullYear(), current.getMonth(), 1));
|
|
108
|
+
current.setMonth(current.getMonth() + 1);
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case 'year':
|
|
112
|
+
current.setMonth(0, 1);
|
|
113
|
+
while (current <= to) {
|
|
114
|
+
dates.push(new Date(current.getFullYear(), 0, 1));
|
|
115
|
+
current.setFullYear(current.getFullYear() + 1);
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
return dates;
|
|
120
|
+
}
|
|
94
121
|
}
|
|
95
122
|
DateUtils.MILLIS = 1;
|
|
96
123
|
DateUtils.SECONDS = 1000 * DateUtils.MILLIS;
|
|
@@ -307,14 +307,21 @@ class RepositoryDatabasePostgres extends RepositoryDatabase_1.default {
|
|
|
307
307
|
continue;
|
|
308
308
|
if (alias !== "")
|
|
309
309
|
alias += ".";
|
|
310
|
-
if (value instanceof Array)
|
|
310
|
+
if (value instanceof Array) {
|
|
311
311
|
where += ` AND ${alias}${column} = ANY(\$${iter++})`;
|
|
312
|
-
|
|
312
|
+
values.push(value);
|
|
313
|
+
}
|
|
314
|
+
else if (value instanceof PgOperator) {
|
|
315
|
+
let idxs = value.vals.map((v) => { values.push(v); return `\$${iter++}`; });
|
|
316
|
+
where += ` AND ${value.toWhere(`${alias}${column}`, idxs)}`;
|
|
317
|
+
}
|
|
318
|
+
else if (value === null) {
|
|
313
319
|
where += ` AND ${alias}${column} IS NULL`;
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
where += ` AND ${alias}${column} = \$${iter++}`;
|
|
317
323
|
values.push(value);
|
|
324
|
+
}
|
|
318
325
|
}
|
|
319
326
|
return { where, values };
|
|
320
327
|
}
|
package/package.json
CHANGED
|
@@ -115,4 +115,37 @@ export default abstract class DateUtils {
|
|
|
115
115
|
|
|
116
116
|
return recursivelyRevive(obj);
|
|
117
117
|
}
|
|
118
|
+
|
|
119
|
+
static split(span: 'year' | 'month' | 'day', from: Date, to: Date): Date[]
|
|
120
|
+
{
|
|
121
|
+
const dates: Date[] = [];
|
|
122
|
+
const current = new Date(from);
|
|
123
|
+
|
|
124
|
+
switch (span) {
|
|
125
|
+
case 'day':
|
|
126
|
+
while (current <= to) {
|
|
127
|
+
dates.push(new Date(current));
|
|
128
|
+
current.setDate(current.getDate() + 1);
|
|
129
|
+
}
|
|
130
|
+
break;
|
|
131
|
+
|
|
132
|
+
case 'month':
|
|
133
|
+
current.setDate(1);
|
|
134
|
+
while (current <= to) {
|
|
135
|
+
dates.push(new Date(current.getFullYear(), current.getMonth(), 1));
|
|
136
|
+
current.setMonth(current.getMonth() + 1);
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
|
|
140
|
+
case 'year':
|
|
141
|
+
current.setMonth(0, 1);
|
|
142
|
+
while (current <= to) {
|
|
143
|
+
dates.push(new Date(current.getFullYear(), 0, 1));
|
|
144
|
+
current.setFullYear(current.getFullYear() + 1);
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return dates;
|
|
150
|
+
}
|
|
118
151
|
}
|
|
@@ -274,10 +274,22 @@ export default class RepositoryDatabasePostgres extends RepositoryDatabase
|
|
|
274
274
|
let column = PostgresUtils.camelToSnake(key);
|
|
275
275
|
if (value === undefined) continue;
|
|
276
276
|
if (alias !== "") alias += "."
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
277
|
+
|
|
278
|
+
if (value instanceof Array) {
|
|
279
|
+
where += ` AND ${alias}${column} = ANY(\$${iter++})`;
|
|
280
|
+
values.push(value);
|
|
281
|
+
|
|
282
|
+
} else if (value instanceof PgOperator) {
|
|
283
|
+
let idxs = value.vals.map((v) => { values.push(v); return `\$${iter++}` });
|
|
284
|
+
where += ` AND ${value.toWhere(`${alias}${column}`, idxs)}`
|
|
285
|
+
|
|
286
|
+
} else if (value === null) {
|
|
287
|
+
where += ` AND ${alias}${column} IS NULL`
|
|
288
|
+
|
|
289
|
+
} else {
|
|
290
|
+
where += ` AND ${alias}${column} = \$${iter++}`;
|
|
291
|
+
values.push(value);
|
|
292
|
+
}
|
|
281
293
|
}
|
|
282
294
|
|
|
283
295
|
return { where, values };
|