signalk-to-noforeignland 0.1.5 → 0.1.7

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.
Files changed (2) hide show
  1. package/index.js +10 -4
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -11,13 +11,13 @@ const isReachable = require('is-reachable');
11
11
  const sendEmail = require('./sendEmail');
12
12
  const createGPX = require('./createGPX');
13
13
  const apiUrl = 'https://www.noforeignland.com/home/api/v1/boat/tracking/track';
14
- const pluginApiKey = 'eef6916b-77fa-4538-9870-034a8ab81989';
14
+ const pluginApiKey = '0ede6cb6-5213-45f5-8ab4-b4836b236f97';
15
15
  // const msToKn = 1.944;
16
16
 
17
17
 
18
18
  module.exports = function (app) {
19
19
  var plugin = {};
20
- plugin.id = 'signalk-to-nfl';
20
+ plugin.id = 'signalk-to-noforeignland';
21
21
  plugin.name = 'SignalK To NFL';
22
22
  plugin.description = 'SignalK track logger to noforeignland.com';
23
23
 
@@ -116,7 +116,7 @@ module.exports = function (app) {
116
116
 
117
117
  var unsubscribes = [];
118
118
  var unsubscribesControl = [];
119
- var routeSaveName = 'track.jsonl';
119
+ var routeSaveName = 'nfl-track.jsonl';
120
120
  let lastPosition;
121
121
  let upSince;
122
122
  let cron;
@@ -397,7 +397,7 @@ module.exports = function (app) {
397
397
  if (responseBody.status === 'ok') {
398
398
  app.debug('Track successfully sent to API');
399
399
  if (options.keepFiles) {
400
- const filename = new Date().toJSON().slice(0, 19).replace(/:/g, '') + '-track.jsonl';
400
+ const filename = new Date().toJSON().slice(0, 19).replace(/:/g, '') + '-nfl-track.jsonl';
401
401
  app.debug('moving and keeping track file: ', filename);
402
402
  await fs.move(path.join(options.trackDir, routeSaveName), path.join(options.trackDir, filename));
403
403
  } else {
@@ -471,6 +471,12 @@ module.exports = function (app) {
471
471
  }
472
472
  await fs.rm(path.join(options.trackDir, routeSaveName));
473
473
  }
474
+ //every 10 minute but staggered to the second so we don't all send at once.
475
+ if (!options.emailCron || options.emailCron === '*/10 * * * *') {
476
+ const startMinute = Math.floor(Math.random() * 10); // Random minute within the 10-minute range
477
+ const startSecond = Math.floor(Math.random() * 60); // Random second within the minute
478
+ options.emailCron = `${startSecond} ${startMinute}/10 * * * *`; // Every 10 minutes, starting at a random minute and second within each 10-minute block
479
+ }
474
480
 
475
481
  upSince = new Date().getTime();
476
482
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "signalk-to-noforeignland",
3
- "version": "0.1.5",
4
- "description": "SignalK track logger to noforeignland.com",
3
+ "version": "0.1.7",
4
+ "description": "SignalK track logger to noforeignland.com ",
5
5
  "main": "index.js",
6
6
  "keywords": [
7
7
  "signalk-node-server-plugin",