agenda 3.0.0 → 3.1.0
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/History.md +16 -0
- package/README.md +3 -3
- package/lib/agenda/database.js +6 -1
- package/lib/agenda/jobs.js +3 -1
- package/lib/job/repeat-every.js +2 -1
- package/package.json +10 -10
package/History.md
CHANGED
|
@@ -3,6 +3,22 @@ Next
|
|
|
3
3
|
|
|
4
4
|
* https://github.com/agenda/agenda/pulls
|
|
5
5
|
|
|
6
|
+
3.1.0 / 2020-04-07
|
|
7
|
+
==================
|
|
8
|
+
|
|
9
|
+
_Stay safe!_
|
|
10
|
+
|
|
11
|
+
* Fix for skipImmediate resetting nextRunAt to current date ([#860](https://github.com/agenda/agenda/pull/860)) (Thanks @AshlinDuncan!)
|
|
12
|
+
* Fix deprecated reconnect options ([#948](https://github.com/agenda/agenda/pull/948)) (Thanks @ekegodigital!)
|
|
13
|
+
* Add ability to set a skip when querying jobs. ([#898](https://github.com/agenda/agenda/pull/898)) (Thanks @cjolif!)
|
|
14
|
+
|
|
15
|
+
Internal:
|
|
16
|
+
* Fixed deprecated MongoDB functions in tests ([#928](https://github.com/agenda/agenda/pull/928)) (Thanks @MichielDeMey!)
|
|
17
|
+
* Updated devDependencies
|
|
18
|
+
|
|
19
|
+
Thank you @koresar, @sampathBlam, and @MichielDeMey helping to review PRs for this release! 👏
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
3.0.0 / 2020-02-13
|
|
7
23
|
==================
|
|
8
24
|
|
package/README.md
CHANGED
|
@@ -487,12 +487,12 @@ console.log('Job successfully saved');
|
|
|
487
487
|
## Managing Jobs
|
|
488
488
|
|
|
489
489
|
|
|
490
|
-
### jobs(mongodb-native query, mongodb-native sort, mongodb-native limit)
|
|
490
|
+
### jobs(mongodb-native query, mongodb-native sort, mongodb-native limit, mongodb-native skip)
|
|
491
491
|
|
|
492
|
-
Lets you query (then sort and
|
|
492
|
+
Lets you query (then sort, limit and skip the result) all of the jobs in the agenda job's database. These are full [mongodb-native](https://github.com/mongodb/node-mongodb-native) `find`, `sort`, `limit` and `skip` commands. See mongodb-native's documentation for details.
|
|
493
493
|
|
|
494
494
|
```js
|
|
495
|
-
const jobs = await agenda.jobs({name: 'printAnalyticsReport'}, {data:-1}, 3);
|
|
495
|
+
const jobs = await agenda.jobs({name: 'printAnalyticsReport'}, {data:-1}, 3, 1);
|
|
496
496
|
// Work with jobs (see below)
|
|
497
497
|
```
|
|
498
498
|
|
package/lib/agenda/database.js
CHANGED
|
@@ -25,8 +25,13 @@ module.exports = function(url, collection, options, cb) {
|
|
|
25
25
|
url = 'mongodb://' + url;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
let reconnectOptions = {autoReconnect: true, reconnectTries: Number.MAX_SAFE_INTEGER, reconnectInterval: this._processEvery};
|
|
29
|
+
if (options && options.useUnifiedTopology && options.useUnifiedTopology === true) {
|
|
30
|
+
reconnectOptions = {};
|
|
31
|
+
}
|
|
32
|
+
|
|
28
33
|
collection = collection || 'agendaJobs';
|
|
29
|
-
options = {
|
|
34
|
+
options = {...reconnectOptions, ...options};
|
|
30
35
|
MongoClient.connect(url, options, (error, client) => {
|
|
31
36
|
if (error) {
|
|
32
37
|
debug('error connecting to MongoDB using collection: [%s]', collection);
|
package/lib/agenda/jobs.js
CHANGED
|
@@ -8,13 +8,15 @@ const {createJob} = require('../utils');
|
|
|
8
8
|
* @param {Object} query object for MongoDB
|
|
9
9
|
* @param {Object} sort object for MongoDB
|
|
10
10
|
* @param {Number} limit number of documents to return from MongoDB
|
|
11
|
+
* @param {Number} number of documents to skip in MongoDB
|
|
11
12
|
* @returns {Promise} resolves when fails or passes
|
|
12
13
|
*/
|
|
13
|
-
module.exports = async function(query = {}, sort = {}, limit = 0) {
|
|
14
|
+
module.exports = async function(query = {}, sort = {}, limit = 0, skip = 0) {
|
|
14
15
|
const result = await this._collection
|
|
15
16
|
.find(query)
|
|
16
17
|
.sort(sort)
|
|
17
18
|
.limit(limit)
|
|
19
|
+
.skip(skip)
|
|
18
20
|
.toArray();
|
|
19
21
|
|
|
20
22
|
return result.map(job => createJob(this, job));
|
package/lib/job/repeat-every.js
CHANGED
|
@@ -13,7 +13,8 @@ module.exports = function(interval, options) {
|
|
|
13
13
|
this.attrs.repeatInterval = interval;
|
|
14
14
|
this.attrs.repeatTimezone = options.timezone ? options.timezone : null;
|
|
15
15
|
if (options.skipImmediate) {
|
|
16
|
-
|
|
16
|
+
// Set the lastRunAt time to the nextRunAt so that the new nextRunAt will be computed in reference to the current value.
|
|
17
|
+
this.attrs.lastRunAt = this.attrs.nextRunAt || new Date();
|
|
17
18
|
this.computeNextRunAt();
|
|
18
19
|
this.attrs.lastRunAt = undefined;
|
|
19
20
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agenda",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Light weight job scheduler for Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"files": [
|
|
@@ -51,23 +51,23 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"blanket": "1.2.3",
|
|
54
|
-
"coveralls": "3.0.
|
|
54
|
+
"coveralls": "3.0.11",
|
|
55
55
|
"delay": "4.3.0",
|
|
56
|
+
"eslint": "6.8.0",
|
|
56
57
|
"eslint-config-xo": "0.27.2",
|
|
57
|
-
"eslint-plugin-ava": "10.0
|
|
58
|
+
"eslint-plugin-ava": "10.2.0",
|
|
58
59
|
"eslint-plugin-eslint-comments": "3.1.2",
|
|
59
|
-
"eslint-plugin-import": "2.20.
|
|
60
|
-
"eslint-plugin-node": "11.
|
|
60
|
+
"eslint-plugin-import": "2.20.2",
|
|
61
|
+
"eslint-plugin-node": "11.1.0",
|
|
61
62
|
"eslint-plugin-unicorn": "16.1.1",
|
|
62
|
-
"eslint": "6.8.0",
|
|
63
63
|
"expect.js": "0.3.1",
|
|
64
|
-
"jsdoc": "3.6.
|
|
64
|
+
"jsdoc": "3.6.4",
|
|
65
65
|
"jsdoc-template": "https://github.com/braintree/jsdoc-template",
|
|
66
|
-
"mocha": "7.
|
|
66
|
+
"mocha": "7.1.1",
|
|
67
67
|
"mocha-lcov-reporter": "1.3.0",
|
|
68
68
|
"q": "1.5.1",
|
|
69
|
-
"sinon": "
|
|
70
|
-
"xo": "0.
|
|
69
|
+
"sinon": "9.0.1",
|
|
70
|
+
"xo": "0.27.2"
|
|
71
71
|
},
|
|
72
72
|
"xo": {
|
|
73
73
|
"space": 2,
|