@etainabl/nodejs-sdk 1.2.3 → 1.2.4

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/package.json +1 -1
  2. package/src/reporting.ts +10 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etainabl/nodejs-sdk",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/mjs/index.js",
6
6
  "author": "Jonathan Lambert <jonathan@etainabl.com>",
package/src/reporting.ts CHANGED
@@ -48,7 +48,15 @@ export const getScheduledReportRunTimes = (schedule: any, limit = 1, taskTime =
48
48
 
49
49
  let startDate = originalStartDate;
50
50
 
51
- const runTimes = Array.from(Array(limit).keys()).map(() => {
51
+ const includeStartDate = taskTime.isSameOrBefore(originalStartDate, 'minute');
52
+
53
+ let runTimes = [] as moment.Moment[];
54
+
55
+ if (includeStartDate) {
56
+ runTimes = [originalStartDate];
57
+ }
58
+
59
+ const scheduleRunTimes = Array.from(Array(includeStartDate ? limit - 1 : limit).keys()).map(() => {
52
60
  const nextRunTime = getNextRunTime(startDate, schedule, taskTime);
53
61
 
54
62
  startDate = nextRunTime.hour(originalStartDate.hour()).minute(originalStartDate.minute());
@@ -56,5 +64,5 @@ export const getScheduledReportRunTimes = (schedule: any, limit = 1, taskTime =
56
64
  return nextRunTime;
57
65
  });
58
66
 
59
- return runTimes;
67
+ return [...runTimes, ...scheduleRunTimes];
60
68
  };