@klapeks/micro-db-utils 0.0.3 → 0.0.4
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.
|
@@ -91,10 +91,10 @@ var AbstractSelectHandler = /** @class */ (function () {
|
|
|
91
91
|
var _a;
|
|
92
92
|
return __awaiter(this, void 0, void 0, function () {
|
|
93
93
|
var stat, time, response, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
94
|
-
var _p;
|
|
94
|
+
var _p, _q;
|
|
95
95
|
var _this = this;
|
|
96
|
-
return __generator(this, function (
|
|
97
|
-
switch (
|
|
96
|
+
return __generator(this, function (_r) {
|
|
97
|
+
switch (_r.label) {
|
|
98
98
|
case 0:
|
|
99
99
|
stat = function (fromDate, time) { return __awaiter(_this, void 0, void 0, function () {
|
|
100
100
|
var isoDate, sum;
|
|
@@ -123,56 +123,60 @@ var AbstractSelectHandler = /** @class */ (function () {
|
|
|
123
123
|
};
|
|
124
124
|
return [4 /*yield*/, this.getTotal()];
|
|
125
125
|
case 1:
|
|
126
|
-
response = (_p.count =
|
|
126
|
+
response = (_p.count = _r.sent(),
|
|
127
127
|
_p);
|
|
128
128
|
_b = response;
|
|
129
|
-
|
|
129
|
+
_q = {
|
|
130
|
+
from: new Date(0)
|
|
131
|
+
};
|
|
132
|
+
return [4 /*yield*/, this.runSQL_One("\n SELECT SUM(".concat(sumField, ") as sum\n FROM ").concat(this.getTableName(), "\n ").concat(strWhere ? ("WHERE " + strWhere) : '', "\n "))];
|
|
130
133
|
case 2:
|
|
131
|
-
_b.total = (_a = (
|
|
134
|
+
_b.total = (_q.sum = (_a = (_r.sent())) === null || _a === void 0 ? void 0 : _a.sum,
|
|
135
|
+
_q);
|
|
132
136
|
_c = response;
|
|
133
137
|
return [4 /*yield*/, stat(new Date())];
|
|
134
138
|
case 3:
|
|
135
|
-
_c.thisDay =
|
|
139
|
+
_c.thisDay = _r.sent();
|
|
136
140
|
_d = response;
|
|
137
141
|
return [4 /*yield*/, stat(function (d) { return d.setDate(d.getDate() - (d.getDay() || 7) + 1); })];
|
|
138
142
|
case 4:
|
|
139
|
-
_d.thisWeek =
|
|
143
|
+
_d.thisWeek = _r.sent();
|
|
140
144
|
_e = response;
|
|
141
145
|
return [4 /*yield*/, stat(function (d) { return d.setDate(1); })];
|
|
142
146
|
case 5:
|
|
143
|
-
_e.thisMonth =
|
|
147
|
+
_e.thisMonth = _r.sent();
|
|
144
148
|
_f = response;
|
|
145
149
|
return [4 /*yield*/, stat(function (d) { d.setMonth(0); d.setDate(1); })];
|
|
146
150
|
case 6:
|
|
147
|
-
_f.thisYear =
|
|
151
|
+
_f.thisYear = _r.sent();
|
|
148
152
|
_g = response;
|
|
149
153
|
return [4 /*yield*/, stat(function (d) { return d.setDate(d.getDate() - 1); }, time)];
|
|
150
154
|
case 7:
|
|
151
|
-
_g.past24hours =
|
|
155
|
+
_g.past24hours = _r.sent();
|
|
152
156
|
_h = response;
|
|
153
157
|
return [4 /*yield*/, stat(function (d) { return d.setDate(d.getDate() - 2); })];
|
|
154
158
|
case 8:
|
|
155
|
-
_h.past3days =
|
|
159
|
+
_h.past3days = _r.sent();
|
|
156
160
|
_j = response;
|
|
157
161
|
return [4 /*yield*/, stat(function (d) { return d.setDate(d.getDate() - 6); })];
|
|
158
162
|
case 9:
|
|
159
|
-
_j.past7days =
|
|
163
|
+
_j.past7days = _r.sent();
|
|
160
164
|
_k = response;
|
|
161
165
|
return [4 /*yield*/, stat(function (d) { return d.setDate(d.getDate() - 13); })];
|
|
162
166
|
case 10:
|
|
163
|
-
_k.past14days =
|
|
167
|
+
_k.past14days = _r.sent();
|
|
164
168
|
_l = response;
|
|
165
169
|
return [4 /*yield*/, stat(function (d) { return d.setDate(d.getDate() - 29); })];
|
|
166
170
|
case 11:
|
|
167
|
-
_l.past30days =
|
|
171
|
+
_l.past30days = _r.sent();
|
|
168
172
|
_m = response;
|
|
169
173
|
return [4 /*yield*/, stat(function (d) { return d.setMonth(d.getMonth() - 6); })];
|
|
170
174
|
case 12:
|
|
171
|
-
_m.past6months =
|
|
175
|
+
_m.past6months = _r.sent();
|
|
172
176
|
_o = response;
|
|
173
177
|
return [4 /*yield*/, stat(function (d) { return d.setMonth(d.getMonth() - 12); })];
|
|
174
178
|
case 13:
|
|
175
|
-
_o.past12months =
|
|
179
|
+
_o.past12months = _r.sent();
|
|
176
180
|
return [2 /*return*/, response];
|
|
177
181
|
}
|
|
178
182
|
});
|