From d0ff49a573fc46c02f958331384ef3f89b3367e2 Mon Sep 17 00:00:00 2001 From: slayer1551 Date: Wed, 1 Jun 2022 13:21:28 +0100 Subject: [PATCH 1/5] Typo --- public/app/js/confirms.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/app/js/confirms.js b/public/app/js/confirms.js index 3b732315..52f38a36 100644 --- a/public/app/js/confirms.js +++ b/public/app/js/confirms.js @@ -1,8 +1,8 @@ const popupmessage = Vue.component("popup-message", { props: ["job", "deletec", "requeuec", "createc"], template: ` -
Job Deleted successfull
-
Job Requeue successfull
-
Job Created successfull
+
Job Deleted successful
+
Job Requeue successful
+
Job Created successful
`, }); From b936d3b3c660cf4093f5c4e44acf08e86393b3bb Mon Sep 17 00:00:00 2001 From: slayer1551 Date: Wed, 1 Jun 2022 13:29:15 +0100 Subject: [PATCH 2/5] Fix new job window modal from not closing --- public/app/js/newJob.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/public/app/js/newJob.js b/public/app/js/newJob.js index ac13e063..3c925fc3 100644 --- a/public/app/js/newJob.js +++ b/public/app/js/newJob.js @@ -38,7 +38,6 @@ const newJob = Vue.component("new-job", { .then((data) => { this.$emit("popup-message"); this.$emit("refresh-data"); - this.$refs.Close.click(); this.clear(); }) .catch(console.log); @@ -79,7 +78,7 @@ const newJob = Vue.component("new-job", { From 9e14bd6675ac0019026b7b0b3b24a850678dcded Mon Sep 17 00:00:00 2001 From: slayer1551 Date: Wed, 1 Jun 2022 13:32:27 +0100 Subject: [PATCH 3/5] AWS Document DB Support $facet is not available in AWS Document DB and throws an error. Created an error check that if it fails with the standard query to try the AWS query to create the pages and filters. --- lib/controllers/agendash.js | 166 +++++++++++++++++++++++------------- 1 file changed, 108 insertions(+), 58 deletions(-) diff --git a/lib/controllers/agendash.js b/lib/controllers/agendash.js index e78b9280..821f3fcb 100644 --- a/lib/controllers/agendash.js +++ b/lib/controllers/agendash.js @@ -39,7 +39,7 @@ module.exports = function (agenda, options) { if (job) { preMatch.name = job; } - + if (options.query && options.property) { if (options.isObjectId) { preMatch[options.property] = ObjectId(options.query); @@ -48,6 +48,7 @@ module.exports = function (agenda, options) { } else { preMatch[options.property] = { $regex: options.query, $options: "i" }; } + } const postMatch = {}; @@ -56,69 +57,118 @@ module.exports = function (agenda, options) { } const collection = agenda._collection.collection || agenda._collection; - return collection - .aggregate([ - { $match: preMatch }, - { - $sort: { - nextRunAt: -1, - lastRunAt: -1, - lastFinishedAt: -1, - }, + const aggregateQuery = [ + { $match: preMatch }, + { + $sort: { + nextRunAt: -1, + lastRunAt: -1, + lastFinishedAt: -1, }, - { - $project: { - job: "$$ROOT", - _id: "$$ROOT._id", - running: { - $and: ["$lastRunAt", { $gt: ["$lastRunAt", "$lastFinishedAt"] }], - }, - scheduled: { - $and: ["$nextRunAt", { $gte: ["$nextRunAt", new Date()] }], - }, - queued: { - $and: [ - "$nextRunAt", - { $gte: [new Date(), "$nextRunAt"] }, - { $gte: ["$nextRunAt", "$lastFinishedAt"] }, - ], - }, - completed: { - $and: [ - "$lastFinishedAt", - { $gt: ["$lastFinishedAt", "$failedAt"] }, - ], - }, - failed: { - $and: [ - "$lastFinishedAt", - "$failedAt", - { $eq: ["$lastFinishedAt", "$failedAt"] }, - ], - }, - repeating: { - $and: ["$repeatInterval", { $ne: ["$repeatInterval", null] }], - }, + }, + { + $project: { + job: "$$ROOT", + _id: "$$ROOT._id", + running: { + $and: ["$lastRunAt", { $gt: ["$lastRunAt", "$lastFinishedAt"] }], + }, + scheduled: { + $and: ["$nextRunAt", { $gte: ["$nextRunAt", new Date()] }], + }, + queued: { + $and: [ + "$nextRunAt", + { $gte: [new Date(), "$nextRunAt"] }, + { $gte: ["$nextRunAt", "$lastFinishedAt"] }, + ], + }, + completed: { + $and: [ + "$lastFinishedAt", + { $gt: ["$lastFinishedAt", "$failedAt"] }, + ], + }, + failed: { + $and: [ + "$lastFinishedAt", + "$failedAt", + { $eq: ["$lastFinishedAt", "$failedAt"] }, + ], + }, + repeating: { + $and: ["$repeatInterval", { $ne: ["$repeatInterval", null] }], }, }, - { $match: postMatch }, - { - $facet: { - pages: [ - { $count: "totalMatchs" }, - { - $project: { - totalPages: { - $ceil: { $divide: ["$totalMatchs", options.limit] }, - }, + }, + { $match: postMatch } + + + ]; + const standardMongoDBQuery = [ + { + $facet: { + pages: [ + { $count: "totalMatchs" }, + { + $project: { + totalPages: { + $ceil: { $divide: ["$totalMatchs", options.limit] }, }, }, - ], - filtered: [{ $skip: options.skip }, { $limit: options.limit }], - }, + }, + ], + filtered: [{ $skip: options.skip }, { $limit: options.limit }], }, - ]) - .toArray(); + }, + { + $project: { + total:12 + } + } + ] + const awsDocumentDBQuery = [ + { + $group: { + _id: null, + totalMatchs: { + $sum: 1 + }, + results: { + $push: '$$ROOT' + } + } + }, + { + $project: { + pages: [{totalPages: '$totalMatchs'}], + filtered: { + $slice: [ + '$results', + options.skip, + options.limit + ] + } + } + } + ] + return collection + .aggregate([...aggregateQuery,...standardMongoDBQuery]) + .toArray() + .then((result) => { + return result; + }) + .catch((error) => { + return collection.aggregate([...aggregateQuery,...awsDocumentDBQuery]) + .toArray() + .then((result) => { + return result; + }) + .catch((error) => { + return error; + }) + }); + }; const getOverview = async () => { From d90ea5f2f0240edd1905f87b1caac401cb97960f Mon Sep 17 00:00:00 2001 From: slayer1551 Date: Wed, 1 Jun 2022 13:58:59 +0100 Subject: [PATCH 4/5] Fix totalPage count Fixed the total page count --- lib/controllers/agendash.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/controllers/agendash.js b/lib/controllers/agendash.js index 821f3fcb..1e2a833e 100644 --- a/lib/controllers/agendash.js +++ b/lib/controllers/agendash.js @@ -106,6 +106,7 @@ module.exports = function (agenda, options) { ]; const standardMongoDBQuery = [ + { $facet: { pages: [ @@ -162,11 +163,14 @@ module.exports = function (agenda, options) { return collection.aggregate([...aggregateQuery,...awsDocumentDBQuery]) .toArray() .then((result) => { + result[0].pages[0].totalPages = Math.ceil(result[0].pages[0].totalPages / options.limit); return result; }) .catch((error) => { return error; }) + + }); }; From 32b3687df518437b771a195b73619fc4a79037dc Mon Sep 17 00:00:00 2001 From: slayer1551 Date: Wed, 1 Jun 2022 14:38:54 +0100 Subject: [PATCH 5/5] Update agendash.js removed line uses for testing --- lib/controllers/agendash.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/controllers/agendash.js b/lib/controllers/agendash.js index 1e2a833e..96e2afc1 100644 --- a/lib/controllers/agendash.js +++ b/lib/controllers/agendash.js @@ -120,11 +120,6 @@ module.exports = function (agenda, options) { }, ], filtered: [{ $skip: options.skip }, { $limit: options.limit }], - }, - }, - { - $project: { - total:12 } } ]