@resolveio/server-lib 9.2.18 → 9.2.19
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/client-server-app.js +1 -55
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +1 -40
- package/collections/app-status.collection.js.map +1 -1
- package/collections/app-version.collection.js +1 -40
- package/collections/app-version.collection.js.map +1 -1
- package/collections/counter.collection.js +1 -43
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +1 -71
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +1 -74
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +1 -55
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +1 -50
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +1 -62
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +1 -44
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +1 -53
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +1 -57
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log.collection.js +1 -72
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +1 -58
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-call.collection.js +1 -51
- package/collections/method-call.collection.js.map +1 -1
- package/collections/method-response.collection.js +1 -55
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +1 -57
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-https-inbound.collection.js +1 -66
- package/collections/monitor-https-inbound.collection.js.map +1 -1
- package/collections/monitor-https-outbound.collection.js +1 -74
- package/collections/monitor-https-outbound.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +1 -68
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +1 -62
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +1 -40
- package/collections/notification.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +1 -93
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +1 -76
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +1 -138
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +1 -79
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +1 -46
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +1 -248
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.js +1 -161
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +1 -72
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +1 -62
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +1 -697
- package/http/auth.js.map +1 -1
- package/http/health.js +1 -10
- package/http/health.js.map +1 -1
- package/http/home.js +1 -64
- package/http/home.js.map +1 -1
- package/index.js +1 -123
- package/index.js.map +1 -1
- package/managers/cron.manager.js +1 -205
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +1 -599
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +1 -1682
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +1 -334
- package/managers/monitor.manager.js.map +1 -1
- package/managers/subscription.manager.js +1 -867
- package/managers/subscription.manager.js.map +1 -1
- package/managers/subscription.performance.js +1 -100
- package/managers/subscription.performance.js.map +1 -1
- package/methods/accounts.js +1 -224
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +1 -449
- package/methods/aws.js.map +1 -1
- package/methods/cloudconvert.js +1 -214
- package/methods/cloudconvert.js.map +1 -1
- package/methods/collections.js +1 -526
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +1 -121
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +1 -1284
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flags.js +1 -8
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +1 -370
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +1 -384
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +1 -685
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +1 -826
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +1 -263
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +1 -3
- package/models/app-status.model.js.map +1 -1
- package/models/app-version.model.js +1 -3
- package/models/app-version.model.js.map +1 -1
- package/models/billing-logged-in-users.model.js +1 -3
- package/models/billing-logged-in-users.model.js.map +1 -1
- package/models/collection-document.model.js +1 -3
- package/models/collection-document.model.js.map +1 -1
- package/models/counter.model.js +1 -3
- package/models/counter.model.js.map +1 -1
- package/models/cron-job-history.model.js +1 -3
- package/models/cron-job-history.model.js.map +1 -1
- package/models/cron-job.model.js +1 -3
- package/models/cron-job.model.js.map +1 -1
- package/models/dialog.model.js +1 -3
- package/models/dialog.model.js.map +1 -1
- package/models/email-history.model.js +1 -3
- package/models/email-history.model.js.map +1 -1
- package/models/email-verified.model.js +1 -3
- package/models/email-verified.model.js.map +1 -1
- package/models/file.model.js +1 -3
- package/models/file.model.js.map +1 -1
- package/models/flag.model.js +1 -3
- package/models/flag.model.js.map +1 -1
- package/models/log-method-latency.model.js +1 -3
- package/models/log-method-latency.model.js.map +1 -1
- package/models/log-subscription.model.js +1 -3
- package/models/log-subscription.model.js.map +1 -1
- package/models/log.model.js +1 -3
- package/models/log.model.js.map +1 -1
- package/models/logged-in-users.model.js +1 -3
- package/models/logged-in-users.model.js.map +1 -1
- package/models/method-call.model.js +1 -3
- package/models/method-call.model.js.map +1 -1
- package/models/method-response.model.js +1 -3
- package/models/method-response.model.js.map +1 -1
- package/models/method.model.js +1 -3
- package/models/method.model.js.map +1 -1
- package/models/monitor-cpu.model.js +1 -3
- package/models/monitor-cpu.model.js.map +1 -1
- package/models/monitor-https-inbound.model.js +1 -3
- package/models/monitor-https-inbound.model.js.map +1 -1
- package/models/monitor-https-outbound.model.js +1 -3
- package/models/monitor-https-outbound.model.js.map +1 -1
- package/models/monitor-memory.model.js +1 -3
- package/models/monitor-memory.model.js.map +1 -1
- package/models/monitor-mongo.model.js +1 -3
- package/models/monitor-mongo.model.js.map +1 -1
- package/models/notification.model.js +1 -3
- package/models/notification.model.js.map +1 -1
- package/models/pagination.model.js +1 -23
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +1 -3
- package/models/permission.model.js.map +1 -1
- package/models/report-builder-dashboard-builder.model.js +1 -3
- package/models/report-builder-dashboard-builder.model.js.map +1 -1
- package/models/report-builder-library.model.js +1 -3
- package/models/report-builder-library.model.js.map +1 -1
- package/models/report-builder-report.model.js +1 -3
- package/models/report-builder-report.model.js.map +1 -1
- package/models/report-builder.model.js +1 -3
- package/models/report-builder.model.js.map +1 -1
- package/models/select-data-label.model.js +1 -3
- package/models/select-data-label.model.js.map +1 -1
- package/models/server-response.model.js +1 -3
- package/models/server-response.model.js.map +1 -1
- package/models/subscription.model.js +1 -3
- package/models/subscription.model.js.map +1 -1
- package/models/support-ticket.model.js +1 -3
- package/models/support-ticket.model.js.map +1 -1
- package/models/user-group.model.js +1 -3
- package/models/user-group.model.js.map +1 -1
- package/models/user-guide.model.js +1 -3
- package/models/user-guide.model.js.map +1 -1
- package/models/user.model.js +1 -3
- package/models/user.model.js.map +1 -1
- package/package.json +2 -1
- package/public_api.js +1 -78
- package/public_api.js.map +1 -1
- package/publications/app-status.js +1 -16
- package/publications/app-status.js.map +1 -1
- package/publications/app-version.js +1 -16
- package/publications/app-version.js.map +1 -1
- package/publications/cron-jobs.js +1 -32
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +1 -36
- package/publications/files.js.map +1 -1
- package/publications/flags.js +1 -22
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +1 -90
- package/publications/logs.js.map +1 -1
- package/publications/method-calls.js +1 -16
- package/publications/method-calls.js.map +1 -1
- package/publications/method-responses.js +1 -16
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +1 -16
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +1 -42
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +1 -89
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +1 -50
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +1 -16
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +1 -16
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +1 -16
- package/publications/user-guides.js.map +1 -1
- package/server-app.js +1 -682
- package/server-app.js.map +1 -1
- package/util/common.js +1 -498
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +1 -452
- package/util/schema-report-builder.js.map +1 -1
package/methods/logs.js
CHANGED
|
@@ -1,371 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.loadLogMethods = void 0;
|
|
40
|
-
var log_collection_1 = require("../collections/log.collection");
|
|
41
|
-
var log_subscription_collection_1 = require("../collections/log-subscription.collection");
|
|
42
|
-
var index_1 = require("../index");
|
|
43
|
-
var log_method_latency_collection_1 = require("../collections/log-method-latency.collection");
|
|
44
|
-
var mongo_manager_1 = require("../managers/mongo.manager");
|
|
45
|
-
function loadLogMethods(methodManager) {
|
|
46
|
-
methodManager.methods({
|
|
47
|
-
insertErrorLog: {
|
|
48
|
-
function: function (message, data) {
|
|
49
|
-
this.sendEmail('dev@resolveio.com', 'Error Detected - ' + index_1.ResolveIOServer.getClientName(), this.user + '\n' + message + '\n' + JSON.stringify(data, null, 2));
|
|
50
|
-
return log_collection_1.Logs.insertOne({
|
|
51
|
-
_id: mongo_manager_1.objectIdHexString(),
|
|
52
|
-
type: 'error',
|
|
53
|
-
collection: '',
|
|
54
|
-
id_document: '',
|
|
55
|
-
payload: JSON.stringify(data, null, 2),
|
|
56
|
-
method: '',
|
|
57
|
-
id_user: this.id_user || '',
|
|
58
|
-
user: this.user || '',
|
|
59
|
-
messageId: 0,
|
|
60
|
-
route: ''
|
|
61
|
-
});
|
|
62
|
-
},
|
|
63
|
-
skipValidation: true
|
|
64
|
-
},
|
|
65
|
-
insertSubscriptionLog: {
|
|
66
|
-
function: function (type, subscription, collection_name, subData) {
|
|
67
|
-
return log_subscription_collection_1.LogSubscriptions.create({
|
|
68
|
-
_id: mongo_manager_1.objectIdHexString(),
|
|
69
|
-
__v: 0,
|
|
70
|
-
date: new Date(),
|
|
71
|
-
type: type,
|
|
72
|
-
subscription: subscription,
|
|
73
|
-
collection_name: collection_name,
|
|
74
|
-
subData: subData
|
|
75
|
-
});
|
|
76
|
-
},
|
|
77
|
-
skipValidation: true
|
|
78
|
-
},
|
|
79
|
-
insertMethodLatencyLog: {
|
|
80
|
-
function: function (method) {
|
|
81
|
-
return log_method_latency_collection_1.LogMethodLatencies.create({
|
|
82
|
-
_id: mongo_manager_1.objectIdHexString(),
|
|
83
|
-
__v: 0,
|
|
84
|
-
date_start: new Date(),
|
|
85
|
-
date_end: null,
|
|
86
|
-
latency_ms: 0,
|
|
87
|
-
method: method
|
|
88
|
-
});
|
|
89
|
-
},
|
|
90
|
-
skipValidation: true
|
|
91
|
-
},
|
|
92
|
-
superadminAPM: {
|
|
93
|
-
function: function (date_start, date_end, graphInterval) {
|
|
94
|
-
var _this = this;
|
|
95
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
96
|
-
var latencies, subscriptions, groupId, groupSort, methodGraphData, subGraphData;
|
|
97
|
-
return __generator(this, function (_a) {
|
|
98
|
-
switch (_a.label) {
|
|
99
|
-
case 0: return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.aggregate([
|
|
100
|
-
{
|
|
101
|
-
$match: {
|
|
102
|
-
$and: [
|
|
103
|
-
{
|
|
104
|
-
createdAt: { $gte: date_start }
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
createdAt: { $lte: date_end }
|
|
108
|
-
}
|
|
109
|
-
]
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
$group: {
|
|
114
|
-
_id: '$method',
|
|
115
|
-
method: { $first: '$method' },
|
|
116
|
-
count: { $sum: 1 },
|
|
117
|
-
latency_min: { $min: '$latency_ms' },
|
|
118
|
-
latency_avg: { $avg: '$latency_ms' },
|
|
119
|
-
latency_max: { $max: '$latency_ms' }
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
], { allowDiskUse: true, readPreference: 'secondary' })];
|
|
123
|
-
case 1:
|
|
124
|
-
latencies = _a.sent();
|
|
125
|
-
return [4 /*yield*/, log_subscription_collection_1.LogSubscriptions.aggregate([
|
|
126
|
-
{
|
|
127
|
-
$match: {
|
|
128
|
-
$and: [
|
|
129
|
-
{
|
|
130
|
-
createdAt: { $gte: date_start }
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
createdAt: { $lte: date_end }
|
|
134
|
-
}
|
|
135
|
-
]
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
$group: {
|
|
140
|
-
_id: '$subscription',
|
|
141
|
-
subscription: { $first: '$subscription' },
|
|
142
|
-
count: { $sum: 1 }
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
], { allowDiskUse: true, readPreference: 'secondary' })];
|
|
146
|
-
case 2:
|
|
147
|
-
subscriptions = _a.sent();
|
|
148
|
-
groupId = {};
|
|
149
|
-
groupSort = {};
|
|
150
|
-
if (graphInterval === 'seconds') {
|
|
151
|
-
groupId = {
|
|
152
|
-
second: {
|
|
153
|
-
$second: {
|
|
154
|
-
date: '$createdAt',
|
|
155
|
-
timezone: "America/Chicago"
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
minute: {
|
|
159
|
-
$minute: {
|
|
160
|
-
date: '$createdAt',
|
|
161
|
-
timezone: "America/Chicago"
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
hour: {
|
|
165
|
-
$hour: {
|
|
166
|
-
date: '$createdAt',
|
|
167
|
-
timezone: "America/Chicago"
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
day: {
|
|
171
|
-
$dayOfMonth: {
|
|
172
|
-
date: '$createdAt',
|
|
173
|
-
timezone: "America/Chicago"
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
month: {
|
|
177
|
-
$month: {
|
|
178
|
-
date: '$createdAt',
|
|
179
|
-
timezone: "America/Chicago"
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
year: {
|
|
183
|
-
$year: {
|
|
184
|
-
date: '$createdAt',
|
|
185
|
-
timezone: "America/Chicago"
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
groupSort = {
|
|
190
|
-
'_id.year': 1,
|
|
191
|
-
'_id.month': 1,
|
|
192
|
-
'_id.day': 1,
|
|
193
|
-
'_id.hour': 1,
|
|
194
|
-
'_id.minute': 1,
|
|
195
|
-
'_id.second': 1
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
else if (graphInterval === 'minutes') {
|
|
199
|
-
groupId = {
|
|
200
|
-
minute: {
|
|
201
|
-
$minute: {
|
|
202
|
-
date: '$createdAt',
|
|
203
|
-
timezone: "America/Chicago"
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
hour: {
|
|
207
|
-
$hour: {
|
|
208
|
-
date: '$createdAt',
|
|
209
|
-
timezone: "America/Chicago"
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
day: {
|
|
213
|
-
$dayOfMonth: {
|
|
214
|
-
date: '$createdAt',
|
|
215
|
-
timezone: "America/Chicago"
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
month: {
|
|
219
|
-
$month: {
|
|
220
|
-
date: '$createdAt',
|
|
221
|
-
timezone: "America/Chicago"
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
year: {
|
|
225
|
-
$year: {
|
|
226
|
-
date: '$createdAt',
|
|
227
|
-
timezone: "America/Chicago"
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
groupSort = {
|
|
232
|
-
'_id.year': 1,
|
|
233
|
-
'_id.month': 1,
|
|
234
|
-
'_id.day': 1,
|
|
235
|
-
'_id.hour': 1,
|
|
236
|
-
'_id.minute': 1
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
else if (graphInterval === 'hours') {
|
|
240
|
-
groupId = {
|
|
241
|
-
hour: {
|
|
242
|
-
$hour: {
|
|
243
|
-
date: '$createdAt',
|
|
244
|
-
timezone: "America/Chicago"
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
day: {
|
|
248
|
-
$dayOfMonth: {
|
|
249
|
-
date: '$createdAt',
|
|
250
|
-
timezone: "America/Chicago"
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
month: {
|
|
254
|
-
$month: {
|
|
255
|
-
date: '$createdAt',
|
|
256
|
-
timezone: "America/Chicago"
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
year: {
|
|
260
|
-
$year: {
|
|
261
|
-
date: '$createdAt',
|
|
262
|
-
timezone: "America/Chicago"
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
groupSort = {
|
|
267
|
-
'_id.year': 1,
|
|
268
|
-
'_id.month': 1,
|
|
269
|
-
'_id.day': 1,
|
|
270
|
-
'_id.hour': 1
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
else {
|
|
274
|
-
groupId = {
|
|
275
|
-
day: {
|
|
276
|
-
$dayOfMonth: {
|
|
277
|
-
date: '$createdAt',
|
|
278
|
-
timezone: "America/Chicago"
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
month: {
|
|
282
|
-
$month: {
|
|
283
|
-
date: '$createdAt',
|
|
284
|
-
timezone: "America/Chicago"
|
|
285
|
-
}
|
|
286
|
-
},
|
|
287
|
-
year: {
|
|
288
|
-
$year: {
|
|
289
|
-
date: '$createdAt',
|
|
290
|
-
timezone: "America/Chicago"
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
groupSort = {
|
|
295
|
-
'_id.year': 1,
|
|
296
|
-
'_id.month': 1,
|
|
297
|
-
'_id.day': 1
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
return [4 /*yield*/, log_method_latency_collection_1.LogMethodLatencies.aggregate([
|
|
301
|
-
{
|
|
302
|
-
$match: {
|
|
303
|
-
$and: [
|
|
304
|
-
{
|
|
305
|
-
createdAt: { $gte: date_start }
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
createdAt: { $lte: date_end }
|
|
309
|
-
}
|
|
310
|
-
]
|
|
311
|
-
}
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
$group: {
|
|
315
|
-
_id: groupId,
|
|
316
|
-
count: {
|
|
317
|
-
$sum: 1
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
$sort: groupSort
|
|
323
|
-
}
|
|
324
|
-
], { allowDiskUse: true, readPreference: 'secondary' })];
|
|
325
|
-
case 3:
|
|
326
|
-
methodGraphData = _a.sent();
|
|
327
|
-
return [4 /*yield*/, log_subscription_collection_1.LogSubscriptions.aggregate([
|
|
328
|
-
{
|
|
329
|
-
$match: {
|
|
330
|
-
$and: [
|
|
331
|
-
{
|
|
332
|
-
createdAt: { $gte: date_start }
|
|
333
|
-
},
|
|
334
|
-
{
|
|
335
|
-
createdAt: { $lte: date_end }
|
|
336
|
-
}
|
|
337
|
-
]
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
$group: {
|
|
342
|
-
_id: groupId,
|
|
343
|
-
count: {
|
|
344
|
-
$sum: 1
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
},
|
|
348
|
-
{
|
|
349
|
-
$sort: groupSort
|
|
350
|
-
}
|
|
351
|
-
], { allowDiskUse: true, readPreference: 'secondary' })];
|
|
352
|
-
case 4:
|
|
353
|
-
subGraphData = _a.sent();
|
|
354
|
-
resolve({
|
|
355
|
-
methods: latencies,
|
|
356
|
-
subscriptions: subscriptions,
|
|
357
|
-
methodGraphData: methodGraphData,
|
|
358
|
-
subGraphData: subGraphData
|
|
359
|
-
});
|
|
360
|
-
return [2 /*return*/];
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
}); });
|
|
364
|
-
},
|
|
365
|
-
skipValidation: true
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
exports.loadLogMethods = loadLogMethods;
|
|
370
|
-
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,o,n){return new(o||(o=Promise))((function(r,a){function fulfilled(e){try{step(n.next(e))}catch(e){a(e)}}function rejected(e){try{step(n.throw(e))}catch(e){a(e)}}function step(e){e.done?r(e.value):function adopt(e){return e instanceof o?e:new o((function(t){t(e)}))}(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())}))},__generator=this&&this.__generator||function(e,t){var o,n,r,a,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return a={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function verb(a){return function(c){return function step(a){if(o)throw new TypeError("Generator is already executing.");for(;i;)try{if(o=1,n&&(r=2&a[0]?n.return:a[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,a[1])).done)return r;switch(n=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){i.label=a[1];break}if(6===a[0]&&i.label<r[1]){i.label=r[1],r=a;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(a);break}r[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{o=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.loadLogMethods=void 0;var log_collection_1=require("../collections/log.collection"),log_subscription_collection_1=require("../collections/log-subscription.collection"),index_1=require("../index"),log_method_latency_collection_1=require("../collections/log-method-latency.collection"),mongo_manager_1=require("../managers/mongo.manager");function loadLogMethods(e){e.methods({insertErrorLog:{function:function(e,t){return this.sendEmail("dev@resolveio.com","Error Detected - "+index_1.ResolveIOServer.getClientName(),this.user+"\n"+e+"\n"+JSON.stringify(t,null,2)),log_collection_1.Logs.insertOne({_id:mongo_manager_1.objectIdHexString(),type:"error",collection:"",id_document:"",payload:JSON.stringify(t,null,2),method:"",id_user:this.id_user||"",user:this.user||"",messageId:0,route:""})},skipValidation:!0},insertSubscriptionLog:{function:function(e,t,o,n){return log_subscription_collection_1.LogSubscriptions.create({_id:mongo_manager_1.objectIdHexString(),__v:0,date:new Date,type:e,subscription:t,collection_name:o,subData:n})},skipValidation:!0},insertMethodLatencyLog:{function:function(e){return log_method_latency_collection_1.LogMethodLatencies.create({_id:mongo_manager_1.objectIdHexString(),__v:0,date_start:new Date,date_end:null,latency_ms:0,method:e})},skipValidation:!0},superadminAPM:{function:function(e,t,o){var n=this;return new Promise((function(r,a){return __awaiter(n,void 0,void 0,(function(){var n,a,i,c,d,s;return __generator(this,(function(l){switch(l.label){case 0:return[4,log_method_latency_collection_1.LogMethodLatencies.aggregate([{$match:{$and:[{createdAt:{$gte:e}},{createdAt:{$lte:t}}]}},{$group:{_id:"$method",method:{$first:"$method"},count:{$sum:1},latency_min:{$min:"$latency_ms"},latency_avg:{$avg:"$latency_ms"},latency_max:{$max:"$latency_ms"}}}],{allowDiskUse:!0,readPreference:"secondary"})];case 1:return n=l.sent(),[4,log_subscription_collection_1.LogSubscriptions.aggregate([{$match:{$and:[{createdAt:{$gte:e}},{createdAt:{$lte:t}}]}},{$group:{_id:"$subscription",subscription:{$first:"$subscription"},count:{$sum:1}}}],{allowDiskUse:!0,readPreference:"secondary"})];case 2:return a=l.sent(),i={},c={},"seconds"===o?(i={second:{$second:{date:"$createdAt",timezone:"America/Chicago"}},minute:{$minute:{date:"$createdAt",timezone:"America/Chicago"}},hour:{$hour:{date:"$createdAt",timezone:"America/Chicago"}},day:{$dayOfMonth:{date:"$createdAt",timezone:"America/Chicago"}},month:{$month:{date:"$createdAt",timezone:"America/Chicago"}},year:{$year:{date:"$createdAt",timezone:"America/Chicago"}}},c={"_id.year":1,"_id.month":1,"_id.day":1,"_id.hour":1,"_id.minute":1,"_id.second":1}):"minutes"===o?(i={minute:{$minute:{date:"$createdAt",timezone:"America/Chicago"}},hour:{$hour:{date:"$createdAt",timezone:"America/Chicago"}},day:{$dayOfMonth:{date:"$createdAt",timezone:"America/Chicago"}},month:{$month:{date:"$createdAt",timezone:"America/Chicago"}},year:{$year:{date:"$createdAt",timezone:"America/Chicago"}}},c={"_id.year":1,"_id.month":1,"_id.day":1,"_id.hour":1,"_id.minute":1}):"hours"===o?(i={hour:{$hour:{date:"$createdAt",timezone:"America/Chicago"}},day:{$dayOfMonth:{date:"$createdAt",timezone:"America/Chicago"}},month:{$month:{date:"$createdAt",timezone:"America/Chicago"}},year:{$year:{date:"$createdAt",timezone:"America/Chicago"}}},c={"_id.year":1,"_id.month":1,"_id.day":1,"_id.hour":1}):(i={day:{$dayOfMonth:{date:"$createdAt",timezone:"America/Chicago"}},month:{$month:{date:"$createdAt",timezone:"America/Chicago"}},year:{$year:{date:"$createdAt",timezone:"America/Chicago"}}},c={"_id.year":1,"_id.month":1,"_id.day":1}),[4,log_method_latency_collection_1.LogMethodLatencies.aggregate([{$match:{$and:[{createdAt:{$gte:e}},{createdAt:{$lte:t}}]}},{$group:{_id:i,count:{$sum:1}}},{$sort:c}],{allowDiskUse:!0,readPreference:"secondary"})];case 3:return d=l.sent(),[4,log_subscription_collection_1.LogSubscriptions.aggregate([{$match:{$and:[{createdAt:{$gte:e}},{createdAt:{$lte:t}}]}},{$group:{_id:i,count:{$sum:1}}},{$sort:c}],{allowDiskUse:!0,readPreference:"secondary"})];case 4:return s=l.sent(),r({methods:n,subscriptions:a,methodGraphData:d,subGraphData:s}),[2]}}))}))}))},skipValidation:!0}})}exports.loadLogMethods=loadLogMethods;
|
|
371
2
|
//# sourceMappingURL=logs.js.map
|
package/methods/logs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/methods/logs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gEAAqD;AACrD,0FAA8E;AAC9E,kCAA2C;AAC3C,8FAAkF;AAClF,2DAA8D;AAE9D,SAAgB,cAAc,CAAC,aAA4B;IAC1D,aAAa,CAAC,OAAO,CAAC;QACrB,cAAc,EAAE;YACf,QAAQ,EAAE,UAAS,OAAO,EAAE,IAAI;gBAC/B,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,u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AE;oDACN,IAAI,EAAE,CAAC;iDACP;6CACD;yCACD;wCACD;4CACC,KAAK,EAAE,SAAS;yCAChB;qCACD,EAAE,EAAC,YAAY,EAAE,IAAI,EAAE,cAAc,EAAE,WAAW,EAAC,CAAC,EAAA;;gCAxBjD,YAAY,GAAG,SAwBkC;gCAErD,OAAO,CAAC;oCACP,OAAO,EAAE,SAAS;oCAClB,aAAa,EAAE,aAAa;oCAC5B,eAAe,EAAE,eAAe;oCAChC,YAAY,EAAE,YAAY;iCAC1B,CAAC,CAAC;;;;qBACH,CAAC,CAAC;YACJ,CAAC;YACD,cAAc,EAAE,IAAI;SACpB;KACD,CAAC,CAAC;AACJ,CAAC;AA/TD,wCA+TC","file":"logs.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\nimport { Logs } from '../collections/log.collection';\nimport { LogSubscriptions } from '../collections/log-subscription.collection';\nimport { ResolveIOServer } from '../index';\nimport { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport { objectIdHexString } from '../managers/mongo.manager';\n\nexport function loadLogMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tinsertErrorLog: {\n\t\t\tfunction: function(message, data) {\n\t\t\t\tthis.sendEmail('dev@resolveio.com', 'Error Detected - ' + ResolveIOServer.getClientName(), this.user + '\\n' + message + '\\n' + JSON.stringify(data, null, 2));\n\n\t\t\t\treturn Logs.insertOne({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\ttype: 'error',\n\t\t\t\t\tcollection: '',\n\t\t\t\t\tid_document: '',\n\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\tmethod: '',\n\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\tmessageId: 0,\n\t\t\t\t\troute: ''\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertSubscriptionLog: {\n\t\t\tfunction: function(type, subscription, collection_name, subData) {\n\t\t\t\treturn LogSubscriptions.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\ttype: type,\n\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\tsubData: subData\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertMethodLatencyLog: {\n\t\t\tfunction: function(method) {\n\t\t\t\treturn LogMethodLatencies.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\tdate_end: null,\n\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\tmethod: method\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tsuperadminAPM: {\n\t\t\tfunction: function(date_start: Date, date_end: Date, graphInterval) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet latencies = await LogMethodLatencies.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: '$method',\n\t\t\t\t\t\t\t\tmethod: {$first: '$method'},\n\t\t\t\t\t\t\t\tcount: {$sum: 1},\n\t\t\t\t\t\t\t\tlatency_min: {$min: '$latency_ms'},\n\t\t\t\t\t\t\t\tlatency_avg: {$avg: '$latency_ms'},\n\t\t\t\t\t\t\t\tlatency_max: {$max: '$latency_ms'}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tlet subscriptions = await LogSubscriptions.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: '$subscription',\n\t\t\t\t\t\t\t\tsubscription: {$first: '$subscription'},\n\t\t\t\t\t\t\t\tcount: {$sum: 1}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tlet groupId = {};\n\t\t\t\t\tlet groupSort = {};\n\n\t\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t\t'_id.minute': 1,\n\t\t\t\t\t\t\t'_id.second': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t\t'_id.minute': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tlet methodGraphData = await LogMethodLatencies.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tlet subGraphData = await LogSubscriptions.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tmethods: latencies,\n\t\t\t\t\t\tsubscriptions: subscriptions,\n\t\t\t\t\t\tmethodGraphData: methodGraphData,\n\t\t\t\t\t\tsubGraphData: subGraphData\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t}\n\t});\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/methods/logs.ts"],"names":["log_collection_1","require","log_subscription_collection_1","index_1","log_method_latency_collection_1","mongo_manager_1","loadLogMethods","methodManager","methods","insertErrorLog","function","message","data","this","sendEmail","ResolveIOServer","getClientName","user","JSON","stringify","Logs","insertOne","_id","objectIdHexString","type","collection","id_document","payload","method","id_user","messageId","route","skipValidation","insertSubscriptionLog","subscription","collection_name","subData","LogSubscriptions","create","__v","date","Date","insertMethodLatencyLog","LogMethodLatencies","date_start","date_end","latency_ms","superadminAPM","graphInterval","_this","Promise","resolve","reject","__awaiter","aggregate","$match","$and","createdAt","$gte","$lte","$group","$first","count","$sum","latency_min","$min","latency_avg","$avg","latency_max","$max","allowDiskUse","readPreference","latencies","_a","sent","subscriptions","groupId","groupSort","second","$second","timezone","minute","$minute","hour","$hour","day","$dayOfMonth","month","$month","year","$year","_id.year","_id.month","_id.day","_id.hour","_id.minute","_id.second","$sort","methodGraphData","subGraphData","exports"],"mappings":"+jDACA,IAAAA,iBAAAC,QAAA,iCACAC,8BAAAD,QAAA,8CACAE,QAAAF,QAAA,YACAG,gCAAAH,QAAA,gDACAI,gBAAAJ,QAAA,6BAEA,SAAgBK,eAAeC,GAC9BA,EAAcC,QAAQ,CACrBC,eAAgB,CACfC,SAAU,SAASC,EAASC,GAG3B,OAFAC,KAAKC,UAAU,oBAAqB,oBAAsBX,QAAAY,gBAAgBC,gBAAiBH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wC,SAAU,oBAGZK,IAAK,CACJC,YAAa,CACZ9C,KAAM,aACNwC,SAAU,oBAGZO,MAAO,CACNC,OAAQ,CACPhD,KAAM,aACNwC,SAAU,oBAGZS,KAAM,CACLC,MAAO,CACNlD,KAAM,aACNwC,SAAU,qBAKbH,EAAY,CACXc,WAAY,EACZC,YAAa,EACbC,UAAW,EACXC,WAAY,KAIblB,EAAU,CACTS,IAAK,CACJC,YAAa,CACZ9C,KAAM,aACNwC,SAAU,oBAGZO,MAAO,CACNC,OAAQ,CACPhD,KAAM,aACNwC,SAAU,oBAGZS,KAAM,CACLC,MAAO,CACNlD,KAAM,aACNwC,SAAU,qBAKbH,EAAY,CACXc,WAAY,EACZC,YAAa,EACbC,UAAW,IAIS,CAAA,EAAMzF,gCAAAuC,mBAAmBW,UAAU,CACxD,CACCC,OAAQ,CACPC,KAAM,CACL,CACCC,UAAW,CAACC,KAAMd,IAEnB,CACCa,UAAW,CAACE,KAAMd,OAKtB,CACCe,OAAQ,CACPtC,IAAKsD,EACLd,MAAO,CACNC,KAAM,KAIT,CACCkC,MAAOpB,IAEN,CAACP,cAAc,EAAMC,eAAgB,sBAErB,OA1Bf2B,EAAkBzB,EAAAC,OA0BH,CAAA,EAAMxE,8BAAAmC,iBAAiBiB,UAAU,CACnD,CACCC,OAAQ,CACPC,KAAM,CACL,CACCC,UAAW,CAACC,KAAMd,IAEnB,CACCa,UAAW,CAACE,KAAMd,OAKtB,CACCe,OAAQ,CACPtC,IAAKsD,EACLd,MAAO,CACNC,KAAM,KAIT,CACCkC,MAAOpB,IAEN,CAACP,cAAc,EAAMC,eAAgB,6BAxBpC4B,EAAe1B,EAAAC,OA0BnBvB,EAAQ,CACP3C,QAASgE,EACTG,cAAeA,EACfuB,gBAAiBA,EACjBC,aAAcA,mBAIjBnE,gBAAgB,KA5TnBoE,QAAA9F,eAAAA","file":"logs.js","sourcesContent":["import { MethodManager } from '../managers/method.manager';\nimport { Logs } from '../collections/log.collection';\nimport { LogSubscriptions } from '../collections/log-subscription.collection';\nimport { ResolveIOServer } from '../index';\nimport { LogMethodLatencies } from '../collections/log-method-latency.collection';\nimport { objectIdHexString } from '../managers/mongo.manager';\n\nexport function loadLogMethods(methodManager: MethodManager) {\n\tmethodManager.methods({\n\t\tinsertErrorLog: {\n\t\t\tfunction: function(message, data) {\n\t\t\t\tthis.sendEmail('dev@resolveio.com', 'Error Detected - ' + ResolveIOServer.getClientName(), this.user + '\\n' + message + '\\n' + JSON.stringify(data, null, 2));\n\n\t\t\t\treturn Logs.insertOne({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\ttype: 'error',\n\t\t\t\t\tcollection: '',\n\t\t\t\t\tid_document: '',\n\t\t\t\t\tpayload: JSON.stringify(data, null, 2),\n\t\t\t\t\tmethod: '',\n\t\t\t\t\tid_user: this.id_user || '',\n\t\t\t\t\tuser: this.user || '',\n\t\t\t\t\tmessageId: 0,\n\t\t\t\t\troute: ''\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertSubscriptionLog: {\n\t\t\tfunction: function(type, subscription, collection_name, subData) {\n\t\t\t\treturn LogSubscriptions.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\ttype: type,\n\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\tcollection_name: collection_name,\n\t\t\t\t\tsubData: subData\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tinsertMethodLatencyLog: {\n\t\t\tfunction: function(method) {\n\t\t\t\treturn LogMethodLatencies.create({\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate_start: new Date(),\n\t\t\t\t\tdate_end: null,\n\t\t\t\t\tlatency_ms: 0,\n\t\t\t\t\tmethod: method\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t},\n\t\tsuperadminAPM: {\n\t\t\tfunction: function(date_start: Date, date_end: Date, graphInterval) {\n\t\t\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t\t\tlet latencies = await LogMethodLatencies.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: '$method',\n\t\t\t\t\t\t\t\tmethod: {$first: '$method'},\n\t\t\t\t\t\t\t\tcount: {$sum: 1},\n\t\t\t\t\t\t\t\tlatency_min: {$min: '$latency_ms'},\n\t\t\t\t\t\t\t\tlatency_avg: {$avg: '$latency_ms'},\n\t\t\t\t\t\t\t\tlatency_max: {$max: '$latency_ms'}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tlet subscriptions = await LogSubscriptions.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: '$subscription',\n\t\t\t\t\t\t\t\tsubscription: {$first: '$subscription'},\n\t\t\t\t\t\t\t\tcount: {$sum: 1}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tlet groupId = {};\n\t\t\t\t\tlet groupSort = {};\n\n\t\t\t\t\tif (graphInterval === 'seconds') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tsecond: {\n\t\t\t\t\t\t\t\t$second: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t\t'_id.minute': 1,\n\t\t\t\t\t\t\t'_id.second': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'minutes') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tminute: {\n\t\t\t\t\t\t\t\t$minute: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1,\n\t\t\t\t\t\t\t'_id.minute': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse if (graphInterval === 'hours') {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\thour: {\n\t\t\t\t\t\t\t\t$hour: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1,\n\t\t\t\t\t\t\t'_id.hour': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tgroupId = {\n\t\t\t\t\t\t\tday: {\n\t\t\t\t\t\t\t\t$dayOfMonth: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tmonth: {\n\t\t\t\t\t\t\t\t$month: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tyear: {\n\t\t\t\t\t\t\t\t$year: {\n\t\t\t\t\t\t\t\t\tdate: '$createdAt',\n\t\t\t\t\t\t\t\t\ttimezone: \"America/Chicago\"\n\t\t\t\t\t\t\t\t} \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tgroupSort = {\n\t\t\t\t\t\t\t'_id.year': 1,\n\t\t\t\t\t\t\t'_id.month': 1,\n\t\t\t\t\t\t\t'_id.day': 1\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\tlet methodGraphData = await LogMethodLatencies.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tlet subGraphData = await LogSubscriptions.aggregate([\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$match: {\n\t\t\t\t\t\t\t\t$and: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$gte: date_start}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tcreatedAt: {$lte: date_end}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$group: {\n\t\t\t\t\t\t\t\t_id: groupId,\n\t\t\t\t\t\t\t\tcount: {\n\t\t\t\t\t\t\t\t\t$sum: 1\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t$sort: groupSort\n\t\t\t\t\t\t}\n\t\t\t\t\t], {allowDiskUse: true, readPreference: 'secondary'});\n\n\t\t\t\t\tresolve({\n\t\t\t\t\t\tmethods: latencies,\n\t\t\t\t\t\tsubscriptions: subscriptions,\n\t\t\t\t\t\tmethodGraphData: methodGraphData,\n\t\t\t\t\t\tsubGraphData: subGraphData\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\tskipValidation: true\n\t\t}\n\t});\n}"]}
|