@webtypen/webframez-core 0.3.1 → 0.3.3

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.
@@ -89,6 +89,9 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
89
89
  if (!this.canStart()) {
90
90
  return false;
91
91
  }
92
+ if (!fs_1.default.existsSync((0, FileFunctions_1.storageDir)("queue"))) {
93
+ fs_1.default.mkdirSync((0, FileFunctions_1.storageDir)("queue"), { recursive: true });
94
+ }
92
95
  const filePath = (0, FileFunctions_1.storageDir)("queue", `worker_${this.workerKey}.json`);
93
96
  let lastLogFile = null;
94
97
  if (fs_1.default.existsSync(filePath)) {
@@ -389,7 +392,7 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
389
392
  const executionKey = (0, moment_timezone_1.default)()
390
393
  .tz(this.workerConfig.timezone ? this.workerConfig.timezone : "Europe/Berlin")
391
394
  .format("YYYYMMDDHHmmss") + StringFunctions_1.StringFunctions.random(24);
392
- const job = yield connection.client
395
+ const jobUpdate = yield connection.client
393
396
  .db(null)
394
397
  .collection("queue_jobs")
395
398
  .findOneAndUpdate({
@@ -400,10 +403,10 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
400
403
  worker: { $in: [null, this.workerKey] },
401
404
  $or: [
402
405
  {
403
- started_at: null,
406
+ not_before: null,
404
407
  },
405
408
  {
406
- started_at: { $lte: now.toDate() },
409
+ not_before: { $lte: now.toDate() },
407
410
  },
408
411
  ],
409
412
  }, {
@@ -416,6 +419,11 @@ class QueueWorkerCommand extends ConsoleCommand_1.ConsoleCommand {
416
419
  sort: { priority: -1, created_at: 1 },
417
420
  returnDocument: "after",
418
421
  });
422
+ const job = jobUpdate && jobUpdate.jobclass && jobUpdate._id
423
+ ? jobUpdate
424
+ : jobUpdate.value && jobUpdate.ok && jobUpdate.value._id && jobUpdate.value.jobclass
425
+ ? jobUpdate.value
426
+ : null;
419
427
  if (!job || !job.jobclass || !job._id) {
420
428
  this.currentJob = null;
421
429
  if (job && job._id) {
@@ -253,6 +253,9 @@ class Datatable {
253
253
  delete entry.skipStats;
254
254
  aggregation.push(entry);
255
255
  }
256
+ else {
257
+ aggregation.push(entry);
258
+ }
256
259
  }
257
260
  }
258
261
  const connection = yield DBConnection_1.DBConnection.getConnection();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webtypen/webframez-core",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "The core package of the typescript based webframez (web-framework) by webtypen.de",
5
5
  "homepage": "https://webtypen.de/",
6
6
  "license": "MIT",
@@ -84,6 +84,10 @@ export class QueueWorkerCommand extends ConsoleCommand {
84
84
  return false;
85
85
  }
86
86
 
87
+ if (!fs.existsSync(storageDir("queue"))) {
88
+ fs.mkdirSync(storageDir("queue"), { recursive: true });
89
+ }
90
+
87
91
  const filePath = storageDir("queue", `worker_${this.workerKey}.json`);
88
92
  let lastLogFile: any = null;
89
93
  if (fs.existsSync(filePath)) {
@@ -465,7 +469,7 @@ export class QueueWorkerCommand extends ConsoleCommand {
465
469
  moment()
466
470
  .tz(this.workerConfig.timezone ? this.workerConfig.timezone : "Europe/Berlin")
467
471
  .format("YYYYMMDDHHmmss") + StringFunctions.random(24);
468
- const job = await connection.client
472
+ const jobUpdate = await connection.client
469
473
  .db(null)
470
474
  .collection("queue_jobs")
471
475
  .findOneAndUpdate(
@@ -478,10 +482,10 @@ export class QueueWorkerCommand extends ConsoleCommand {
478
482
  worker: { $in: [null, this.workerKey] },
479
483
  $or: [
480
484
  {
481
- started_at: null,
485
+ not_before: null,
482
486
  },
483
487
  {
484
- started_at: { $lte: now.toDate() },
488
+ not_before: { $lte: now.toDate() },
485
489
  },
486
490
  ],
487
491
  },
@@ -498,6 +502,13 @@ export class QueueWorkerCommand extends ConsoleCommand {
498
502
  }
499
503
  );
500
504
 
505
+ const job =
506
+ jobUpdate && jobUpdate.jobclass && jobUpdate._id
507
+ ? jobUpdate
508
+ : jobUpdate.value && jobUpdate.ok && jobUpdate.value._id && jobUpdate.value.jobclass
509
+ ? jobUpdate.value
510
+ : null;
511
+
501
512
  if (!job || !job.jobclass || !job._id) {
502
513
  this.currentJob = null;
503
514
 
@@ -262,6 +262,8 @@ export class Datatable {
262
262
  if (entry.skipStats) {
263
263
  delete entry.skipStats;
264
264
  aggregation.push(entry);
265
+ } else {
266
+ aggregation.push(entry);
265
267
  }
266
268
  }
267
269
  }