From 8213dd4ac0710ea944f76b512866429b4c1083f2 Mon Sep 17 00:00:00 2001 From: Kenn Sippell Date: Mon, 2 Oct 2023 21:00:25 -0700 Subject: [PATCH] Eslint --- src/nools/definition-preparation.js | 4 ++-- src/nools/task-emitter.js | 37 ++++++++++++++--------------- src/nools/task-recurring.js | 4 ++-- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/nools/definition-preparation.js b/src/nools/definition-preparation.js index 76fc6a4d6..5a2de1c22 100644 --- a/src/nools/definition-preparation.js +++ b/src/nools/definition-preparation.js @@ -1,4 +1,4 @@ -const Luxon = require('luxon'); +const luxon = require('luxon'); /* Declarative tasks and targets (the elements exported by partner task.js and target.js files), are complex objects containing functions. @@ -18,7 +18,7 @@ function bindAllFunctionsToContext(obj, context) { var key = keys[i]; switch(typeof obj[key]) { case 'object': - const isLuxon = Luxon.Duration.isDuration(obj[key]) || Luxon.DateTime.isDateTime(obj[key]); + var isLuxon = luxon.Duration.isDuration(obj[key]) || luxon.DateTime.isDateTime(obj[key]); if (!isLuxon) { bindAllFunctionsToContext(obj[key], context); } diff --git a/src/nools/task-emitter.js b/src/nools/task-emitter.js index 219d46e4c..2746bef66 100644 --- a/src/nools/task-emitter.js +++ b/src/nools/task-emitter.js @@ -1,6 +1,6 @@ const prepareDefinition = require('./definition-preparation'); const taskDefaults = require('./task-defaults'); -const emitRecurringEvents = require('./task-recurring'); +const getRecurringTasks = require('./task-recurring'); function taskEmitter(taskDefinitions, c, Utils, Task, emit) { if (!taskDefinitions) return; @@ -25,8 +25,8 @@ function taskEmitter(taskDefinitions, c, Utils, Task, emit) { switch (taskDefinition.appliesTo) { case 'reports': case 'scheduled_tasks': - for (let idx2=0; idx2 { - emitTaskEvent(emitterContext, partialEmission); + emissionInfo.forEach(emission => { + emitTaskEvent(emitterContext, emission); }); } @@ -149,22 +148,22 @@ function emitTaskDefinition(emitterContext) { return result; } - function emitTaskEvent(emitterContext, partialEmission, scheduledTaskIdx) { + function emitTaskEvent(emitterContext, emissionInfo, scheduledTaskIdx) { const { taskDefinition, Utils, c, r, emit, Task } = emitterContext; - if (!partialEmission._id) { - throw 'partialEmission._id'; + if (!emissionInfo._id) { + throw 'emissionInfo._id'; } - if (!partialEmission.date) { - throw 'partialEmission.date'; + if (!emissionInfo.date) { + throw 'emissionInfo.date'; } - if (!partialEmission.event) { - throw 'partialEmission.event'; + if (!emissionInfo.event) { + throw 'emissionInfo.event'; } - const { event, date: dueDate } = partialEmission; + const { event, date: dueDate } = emissionInfo; if (!Utils.isTimely(dueDate, event)) { return; } @@ -197,7 +196,7 @@ function emitTaskDefinition(emitterContext) { defaultEmission.priorityLabel = priority.label; } - const emission = Object.assign({}, defaultEmission, partialEmission); + const emission = Object.assign({}, defaultEmission, emissionInfo); delete emission.event; emit('task', new Task(emission)); } diff --git a/src/nools/task-recurring.js b/src/nools/task-recurring.js index 784f8360f..7a35491f4 100644 --- a/src/nools/task-recurring.js +++ b/src/nools/task-recurring.js @@ -57,7 +57,7 @@ function getRecurringInterval(events) { function getCriteriaInterval(recurringInterval, timelyInterval, events) { const expandedTimelyInterval = Interval.fromDateTimes( timelyInterval.start.plus({ days: -events.end || 0 }), - timelyInterval.end.plus({ days: events.start || 0 }), + timelyInterval.end.plus({ days: events.start || 0 }) ); return recurringInterval.intersection(expandedTimelyInterval); } @@ -100,7 +100,7 @@ function getIterationInterval(events, recurringInterval, criteriaInterval, perio return Interval.fromDateTimes( advanceDateTimeUsingPeriod(recurringInterval.start, startWithoutPeriod), - advanceDateTimeUsingPeriod(recurringInterval.end, endWithoutPeriod, false), + advanceDateTimeUsingPeriod(recurringInterval.end, endWithoutPeriod, false) ); }