@resolveio/server-lib 9.9.7 → 9.9.8

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.
@@ -14,6 +14,7 @@ interface MongoQueueModel {
14
14
  cbs_next: Function[];
15
15
  running: boolean;
16
16
  cacheId: number;
17
+ invalidateFlag: boolean;
17
18
  }
18
19
  export declare class MongoManager {
19
20
  private _collections;
@@ -85,6 +85,9 @@ var MongoManager = /** @class */ (function () {
85
85
  MongoManager.prototype.addToQueue = function (mongoQueue) {
86
86
  var _mongoQueue = this._mongoQueue.filter(function (a) { return a.name_collection === mongoQueue.name_collection && a.name_function === mongoQueue.name_function && a.name_function_addt === mongoQueue.name_function_addt && JSON.stringify(a.data_function) === JSON.stringify(mongoQueue.data_function) && JSON.stringify(a.data_function_addt) === JSON.stringify(mongoQueue.data_function_addt); })[0];
87
87
  if (_mongoQueue) {
88
+ if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
89
+ console.log(new Date(), 'Add To queue - found queue', mongoQueue.running, mongoQueue.name_function, mongoQueue.data_function);
90
+ }
88
91
  if (!_mongoQueue.running) {
89
92
  _mongoQueue.cbs.push(mongoQueue.cbs[0]);
90
93
  }
@@ -93,6 +96,9 @@ var MongoManager = /** @class */ (function () {
93
96
  }
94
97
  }
95
98
  else {
99
+ if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
100
+ console.log(new Date(), 'Add To queue - new queue', mongoQueue.name_function, mongoQueue.data_function);
101
+ }
96
102
  mongoQueue._id = this._mongoQueueId;
97
103
  this._mongoQueueId += 1;
98
104
  this._mongoQueue.splice(0, 0, mongoQueue);
@@ -111,6 +117,10 @@ var MongoManager = /** @class */ (function () {
111
117
  var _a, _b, _c;
112
118
  var mongoQueue = queueArr[i];
113
119
  mongoQueue.running = true;
120
+ mongoQueue.invalidateFlag = false;
121
+ if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
122
+ console.log(new Date(), 'Add To queue - new queue', mongoQueue.name_function, mongoQueue.data_function);
123
+ }
114
124
  if (mongoQueue.cacheId) {
115
125
  var res_1 = JSON.parse(_this._nodeCache.get(mongoQueue.cacheId), common_1.dateReviver);
116
126
  mongoQueue.cbs.forEach(function (cb) {
@@ -122,12 +132,17 @@ var MongoManager = /** @class */ (function () {
122
132
  else {
123
133
  if (!mongoQueue.name_function_addt) {
124
134
  (_a = index_1.ResolveIOServer.getMainDB().collection(mongoQueue.name_collection))[mongoQueue.name_function].apply(_a, mongoQueue.data_function).then(function (res) {
125
- mongoQueue.cacheId = _this._mongoQueueCacheId;
126
- _this._mongoQueueCacheId += 1;
127
- _this.addToCache(mongoQueue.cacheId, res);
128
- mongoQueue.cbs.forEach(function (cb) {
129
- cb(null, res, false);
130
- });
135
+ if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
136
+ console.log(new Date(), 'After Funct 1', mongoQueue.invalidateFlag, mongoQueue.running, mongoQueue.name_function, mongoQueue.data_function, mongoQueue.cbs_next.length);
137
+ }
138
+ if (!mongoQueue.invalidateFlag) {
139
+ mongoQueue.cacheId = _this._mongoQueueCacheId;
140
+ _this._mongoQueueCacheId += 1;
141
+ _this.addToCache(mongoQueue.cacheId, res);
142
+ mongoQueue.cbs.forEach(function (cb) {
143
+ cb(null, res, false);
144
+ });
145
+ }
131
146
  if (mongoQueue.cbs_next.length) {
132
147
  mongoQueue.cbs = mongoQueue.cbs_next;
133
148
  mongoQueue.cbs_next = [];
@@ -150,12 +165,17 @@ var MongoManager = /** @class */ (function () {
150
165
  }
151
166
  else {
152
167
  (_b = (_c = index_1.ResolveIOServer.getMainDB().collection(mongoQueue.name_collection))[mongoQueue.name_function].apply(_c, mongoQueue.data_function))[mongoQueue.name_function_addt].apply(_b, mongoQueue.data_function_addt).then(function (res) {
153
- mongoQueue.cacheId = _this._mongoQueueCacheId;
154
- _this._mongoQueueCacheId += 1;
155
- _this.addToCache(mongoQueue.cacheId, res);
156
- mongoQueue.cbs.forEach(function (cb) {
157
- cb(null, res, false);
158
- });
168
+ if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
169
+ console.log(new Date(), 'After Funct 2', mongoQueue.invalidateFlag, mongoQueue.running, mongoQueue.name_function, mongoQueue.data_function, mongoQueue.cbs_next.length);
170
+ }
171
+ if (!mongoQueue.invalidateFlag) {
172
+ mongoQueue.cacheId = _this._mongoQueueCacheId;
173
+ _this._mongoQueueCacheId += 1;
174
+ _this.addToCache(mongoQueue.cacheId, res);
175
+ mongoQueue.cbs.forEach(function (cb) {
176
+ cb(null, res, false);
177
+ });
178
+ }
159
179
  if (mongoQueue.cbs_next.length) {
160
180
  mongoQueue.cbs = mongoQueue.cbs_next;
161
181
  mongoQueue.cbs_next = [];
@@ -206,6 +226,9 @@ var MongoManager = /** @class */ (function () {
206
226
  if (nodeCacheSize < this._heapLimit * 0.75) {
207
227
  break;
208
228
  }
229
+ if (queue.name_collection !== 'logged-in-users' && queue.name_collection !== 'cron-jobs') {
230
+ console.log(new Date(), 'Deleting Cache', queue.running, queue.name_function, queue.data_function);
231
+ }
209
232
  }
210
233
  console.log('Query Cache: ' + 'Too Big, - Deleted: ' + deleteCount + ' - ' + nodeCacheSize);
211
234
  }
@@ -215,11 +238,12 @@ var MongoManager = /** @class */ (function () {
215
238
  var queueArr = this._mongoQueue.filter(function (a) { return (a.name_collection === collection || a.lookup_collections.includes(collection)); });
216
239
  for (var i = queueArr.length - 1; i >= 0; i--) {
217
240
  var queue = queueArr[i];
218
- if (queue.name_collection !== 'logged-in-users' && queue.name_collection !== 'cron-jobs') {
219
- console.log(new Date(), 'Invalidate Query: ', queue.name_collection, queue.name_function, queue.data_function);
220
- }
221
241
  this._nodeCache.del(queue.cacheId);
222
242
  queue.cacheId = 0;
243
+ queue.invalidateFlag = true;
244
+ if (queue.name_collection !== 'logged-in-users' && queue.name_collection !== 'cron-jobs') {
245
+ console.log(new Date(), 'Invalidate query', queue.running, queue.name_function, queue.data_function);
246
+ }
223
247
  if (queue.running) {
224
248
  this.addToQueue(queue);
225
249
  }
@@ -322,7 +346,8 @@ var Collection = /** @class */ (function () {
322
346
  cacheId: 0,
323
347
  lookup_collections: pipeline.filter(function (a) { return a['$lookup'] && a['$lookup'].from; }).map(function (a) { return a['$lookup'].from; }).filter(function (elem, index, self) {
324
348
  return index === self.indexOf(elem);
325
- })
349
+ }),
350
+ invalidateFlag: false
326
351
  });
327
352
  }
328
353
  else {
@@ -353,7 +378,8 @@ var Collection = /** @class */ (function () {
353
378
  cacheId: 0,
354
379
  lookup_collections: pipeline.filter(function (a) { return a['$lookup'] && a['$lookup'].from; }).map(function (a) { return a['$lookup'].from; }).filter(function (elem, index, self) {
355
380
  return index === self.indexOf(elem);
356
- })
381
+ }),
382
+ invalidateFlag: false
357
383
  });
358
384
  });
359
385
  };
@@ -538,7 +564,8 @@ var Collection = /** @class */ (function () {
538
564
  cbs_next: [],
539
565
  running: false,
540
566
  cacheId: 0,
541
- lookup_collections: []
567
+ lookup_collections: [],
568
+ invalidateFlag: false
542
569
  });
543
570
  }
544
571
  else {
@@ -590,7 +617,8 @@ var Collection = /** @class */ (function () {
590
617
  cbs_next: [],
591
618
  running: false,
592
619
  cacheId: 0,
593
- lookup_collections: []
620
+ lookup_collections: [],
621
+ invalidateFlag: false
594
622
  });
595
623
  }
596
624
  else {