Socket
Socket
Sign inDemoInstall

jsreport-scheduling

Package Overview
Dependencies
18
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.5 to 2.0.6

34

lib/jobProcessor.js
const parseCron = require('./parseCron')
module.exports = class JobProcessor {
constructor (executionHandler, documentStore, logger, TaskType, options) {
constructor (executionHandler, documentStore, logger, TaskType, Request, options) {
if (!options.taskPingTimeout) {

@@ -15,2 +15,3 @@ options.taskPingTimeout = 2 * options.interval

this.TaskType = TaskType
this.Request = Request

@@ -91,4 +92,12 @@ options.now = options.now || function () {

// someone could have deleted schedule, ignore these tasks
return tasks.filter((t) => t.schedule != null)
// someone could have deleted schedule or disable the schedule, ignore these tasks
return tasks.filter((t) => {
let result = t.schedule != null
if (!result) {
return result
}
return t.schedule.enabled !== false
})
}

@@ -105,3 +114,7 @@

state: 'planned'
}, {$set: {state: 'planning'}})
}, { $set: { state: 'planning' } }, this.Request({
context: {
skipModificationDateUpdate: true
}
}))

@@ -143,3 +156,14 @@ if (count === 1) {

await this.documentStore.collection('schedules').update({ _id: schedule._id }, {$set: {state: 'planned', nextRun: new Date(nextRun.getTime())}})
await this.documentStore.collection('schedules').update({
_id: schedule._id
}, {
$set: {
state: 'planned',
nextRun: new Date(nextRun.getTime())
}
}, this.Request({
context: {
skipModificationDateUpdate: true
}
}))
}

@@ -146,0 +170,0 @@

34

lib/scheduling.js

@@ -9,3 +9,2 @@ /*!

const moment = require('moment')
const nanoid = require('nanoid')

@@ -18,11 +17,7 @@ class Scheduling {

this.ScheduleType = this.reporter.documentStore.registerEntityType('ScheduleType', {
_id: {type: 'Edm.String', key: true},
cron: {type: 'Edm.String'},
name: {type: 'Edm.String', publicKey: true},
templateShortid: {type: 'Edm.String'},
creationDate: {type: 'Edm.DateTimeOffset'},
nextRun: {type: 'Edm.DateTimeOffset'},
shortid: {type: 'Edm.String'},
enabled: {type: 'Edm.Boolean'},
modificationDate: {type: 'Edm.DateTimeOffset'},
state: {type: 'Edm.String'}

@@ -32,5 +27,3 @@ })

this.TaskType = this.reporter.documentStore.registerEntityType('TaskType', {
_id: {type: 'Edm.String', key: true},
scheduleShortid: {type: 'Edm.String'},
creationDate: {type: 'Edm.DateTimeOffset'},
finishDate: {type: 'Edm.DateTimeOffset'},

@@ -122,4 +115,2 @@ state: {type: 'Edm.String'},

_beforeCreateHandler (entity) {
entity.shortid = entity.shortid || nanoid(7)
if (!entity.cron) {

@@ -132,4 +123,2 @@ throw this.reporter.createError('cron expression must be set', {

entity.state = 'planned'
entity.creationDate = new Date()
entity.modificationDate = new Date()
entity.enabled = entity.enabled !== false // default false

@@ -145,3 +134,3 @@ this._updateNextRun(entity)

_beforeUpdateHandler (query, update) {
async _beforeUpdateHandler (query, update, opts, req) {
const entity = update.$set

@@ -151,3 +140,2 @@

if (entity.name && entity.state) {
entity.modificationDate = new Date()
this._updateNextRun(entity)

@@ -168,2 +156,13 @@ entity.state = 'planned'

}
if (entity.enabled === false) {
const scheds = await this.reporter.documentStore.collection('schedules').find(query, req)
await Promise.all(scheds.map(async (sched) => {
await this.reporter.documentStore.collection('tasks').remove({
state: 'running',
scheduleShortid: sched.shortid
}, req)
}))
}
}

@@ -210,3 +209,10 @@

reporter.scheduling.jobProcessor = new JobProcessor(reporter.scheduling.renderReport.bind(reporter.scheduling), reporter.documentStore, reporter.logger, reporter.scheduling.TaskType, definition.options)
reporter.scheduling.jobProcessor = new JobProcessor(
reporter.scheduling.renderReport.bind(reporter.scheduling),
reporter.documentStore,
reporter.logger,
reporter.scheduling.TaskType,
reporter.Request,
definition.options
)

@@ -213,0 +219,0 @@ if (definition.options.autoStart !== false) {

{
"name": "jsreport-scheduling",
"version": "2.0.5",
"version": "2.0.6",
"description": "jsreport extension for scheduling background rendering jobs",

@@ -34,5 +34,4 @@ "scripts": {

"dependencies": {
"cron-parser": "2.5.0",
"moment": "2.22.1",
"nanoid": "1.0.2"
"cron-parser": "2.7.3",
"moment": "2.24.0"
},

@@ -43,3 +42,3 @@ "author": "Jan Blaha",

"cron-builder": "0.3.0",
"cronstrue": "1.5.0",
"cronstrue": "1.64.0",
"eslint": "4.19.1",

@@ -49,10 +48,10 @@ "eslint-config-standard-jsx": "5.0.0",

"in-publish": "2.0.0",
"jsreport-core": "2.3.2",
"jsreport-reports": "2.1.1",
"jsreport-core": "2.4.0",
"jsreport-reports": "2.1.2",
"jsreport-studio-dev": "1.3.2",
"jsreport-templates": "2.1.0",
"lodash": "4.17.5",
"jsreport-templates": "2.2.0",
"lodash": "4.17.11",
"mocha": "5.2.0",
"ordinal-number-suffix": "0.1.1",
"should": "13.2.1",
"ordinal-number-suffix": "0.1.2",
"should": "13.2.3",
"standard": "11.0.1"

@@ -59,0 +58,0 @@ },

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc