@klapeks/micro-db-utils 0.0.16 → 0.0.17
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.
|
@@ -97,13 +97,13 @@ var AbstractSelectHandler = /** @class */ (function () {
|
|
|
97
97
|
});
|
|
98
98
|
};
|
|
99
99
|
AbstractSelectHandler.prototype.getSumStatistic = function (sumField, strWhere) {
|
|
100
|
-
var _a;
|
|
100
|
+
var _a, _b;
|
|
101
101
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
var stat, time, response,
|
|
103
|
-
var
|
|
102
|
+
var stat, time, response, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
103
|
+
var _q, _r;
|
|
104
104
|
var _this = this;
|
|
105
|
-
return __generator(this, function (
|
|
106
|
-
switch (
|
|
105
|
+
return __generator(this, function (_s) {
|
|
106
|
+
switch (_s.label) {
|
|
107
107
|
case 0:
|
|
108
108
|
stat = function (fromDate, time) { return __awaiter(_this, void 0, void 0, function () {
|
|
109
109
|
var expr, isoDate, sum;
|
|
@@ -128,65 +128,65 @@ var AbstractSelectHandler = /** @class */ (function () {
|
|
|
128
128
|
});
|
|
129
129
|
}); };
|
|
130
130
|
time = new Date().toLocaleTimeString('uk-UA');
|
|
131
|
-
|
|
131
|
+
_q = {
|
|
132
132
|
serverTime: time
|
|
133
133
|
};
|
|
134
|
-
return [4 /*yield*/, this.
|
|
134
|
+
return [4 /*yield*/, this.runSQL_One("\n SELECT COUNT(1) AS count\n FROM ".concat(this.getTableName(), " \n ").concat(strWhere ? ("WHERE " + strWhere) : '', "\n "))];
|
|
135
135
|
case 1:
|
|
136
|
-
response = (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
response = (_q.count = (_a = (_s.sent())) === null || _a === void 0 ? void 0 : _a.count,
|
|
137
|
+
_q);
|
|
138
|
+
_c = response;
|
|
139
|
+
_r = {
|
|
140
140
|
from: new Date(0)
|
|
141
141
|
};
|
|
142
|
-
return [4 /*yield*/, this.runSQL_One("\n SELECT SUM(".concat(sumField, ")
|
|
142
|
+
return [4 /*yield*/, this.runSQL_One("\n SELECT SUM(".concat(sumField, ") AS sum\n FROM ").concat(this.getTableName(), "\n ").concat(strWhere ? ("WHERE " + strWhere) : '', "\n "))];
|
|
143
143
|
case 2:
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
_c.total = (_r.sum = (_b = (_s.sent())) === null || _b === void 0 ? void 0 : _b.sum,
|
|
145
|
+
_r);
|
|
146
|
+
_d = response;
|
|
147
147
|
return [4 /*yield*/, stat(new Date())];
|
|
148
148
|
case 3:
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
_d.thisDay = _s.sent();
|
|
150
|
+
_e = response;
|
|
151
151
|
return [4 /*yield*/, stat(function (d) { return d.setDate(d.getDate() - (d.getDay() || 7) + 1); })];
|
|
152
152
|
case 4:
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
_e.thisWeek = _s.sent();
|
|
154
|
+
_f = response;
|
|
155
155
|
return [4 /*yield*/, stat(function (d) { return d.setDate(1); })];
|
|
156
156
|
case 5:
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
_f.thisMonth = _s.sent();
|
|
158
|
+
_g = response;
|
|
159
159
|
return [4 /*yield*/, stat(function (d) { d.setMonth(0); d.setDate(1); })];
|
|
160
160
|
case 6:
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
_g.thisYear = _s.sent();
|
|
162
|
+
_h = response;
|
|
163
163
|
return [4 /*yield*/, stat(function (d) { return d.setDate(d.getDate() - 1); }, time)];
|
|
164
164
|
case 7:
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
_h.past24hours = _s.sent();
|
|
166
|
+
_j = response;
|
|
167
167
|
return [4 /*yield*/, stat(function (d) { return d.setDate(d.getDate() - 2); })];
|
|
168
168
|
case 8:
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
_j.past3days = _s.sent();
|
|
170
|
+
_k = response;
|
|
171
171
|
return [4 /*yield*/, stat(function (d) { return d.setDate(d.getDate() - 6); })];
|
|
172
172
|
case 9:
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
_k.past7days = _s.sent();
|
|
174
|
+
_l = response;
|
|
175
175
|
return [4 /*yield*/, stat(function (d) { return d.setDate(d.getDate() - 13); })];
|
|
176
176
|
case 10:
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
_l.past14days = _s.sent();
|
|
178
|
+
_m = response;
|
|
179
179
|
return [4 /*yield*/, stat(function (d) { return d.setDate(d.getDate() - 29); })];
|
|
180
180
|
case 11:
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
_m.past30days = _s.sent();
|
|
182
|
+
_o = response;
|
|
183
183
|
return [4 /*yield*/, stat(function (d) { return d.setMonth(d.getMonth() - 6); })];
|
|
184
184
|
case 12:
|
|
185
|
-
|
|
186
|
-
|
|
185
|
+
_o.past6months = _s.sent();
|
|
186
|
+
_p = response;
|
|
187
187
|
return [4 /*yield*/, stat(function (d) { return d.setMonth(d.getMonth() - 12); })];
|
|
188
188
|
case 13:
|
|
189
|
-
|
|
189
|
+
_p.past12months = _s.sent();
|
|
190
190
|
return [2 /*return*/, response];
|
|
191
191
|
}
|
|
192
192
|
});
|