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.4.0 to 2.5.0

4

jsreport.config.js

@@ -14,3 +14,5 @@ module.exports = {

maxParallelJobs: { type: 'number' },
taskPingTimeout: { type: 'number' }
taskPingTimeout: { type: 'number' },
cleanScheduleHistoryInterval: { type: 'number' },
maxHistoryPerSchedule: { type: 'number' }
}

@@ -17,0 +19,0 @@ }

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

this.definition = definition
this.cleanScheduleHistoryRunning = false

@@ -86,2 +87,8 @@ this.beforeProcessJobListeners = reporter.createListenerCollection()

})
if (definition.options.cleanScheduleHistoryInterval && definition.options.maxHistoryPerSchedule) {
this.reporter.logger.info(`scheduling extension has enabled schedule history cleanup with interval ${definition.options.cleanScheduleHistoryInterval}ms and max history of ${definition.options.maxHistoryPerSchedule} per schedule`)
this.cleanScheduleHistoryIntervalTimer = setInterval(() => this.cleanScheduleHistory(), definition.options.cleanScheduleHistoryInterval)
this.cleanScheduleHistoryIntervalTimer.unref()
}
}

@@ -292,2 +299,41 @@

async cleanScheduleHistory () {
if (this.cleanScheduleHistoryRunning) {
return
}
this.cleanScheduleHistoryRunning = true
try {
this.reporter.logger.debug('Cleaning up schedule history')
const schedules = await this.reporter.documentStore.collection('schedules').find({})
const tasksToRemove = []
for (const schedule of schedules) {
const scheduleTasks = await this.reporter.documentStore.collection('tasks').find({
scheduleShortid: schedule.shortid,
state: { $in: ['error', 'canceled', 'success'] }
}).sort({ creationDate: -1 })
const filteredTasks = scheduleTasks.slice(this.definition.options.maxHistoryPerSchedule)
if (filteredTasks.length === 0) {
continue
}
tasksToRemove.push(...filteredTasks)
}
if (tasksToRemove.length !== 0) {
this.reporter.logger.debug(`Cleaning schedule history ${tasksToRemove.length} records`)
await Promise.all(tasksToRemove.map((t) => this.reporter.documentStore.collection('tasks').remove({ _id: t._id })))
}
} catch (e) {
this.reporter.logger.error('Failed to clean up schedule history', e)
}
this.cleanScheduleHistoryRunning = false
}
renderReport (schedule, task) {

@@ -331,3 +377,6 @@ return this.reporter.render({

reporter.closeListeners.add('scheduling', () => reporter.scheduling.stop())
reporter.closeListeners.add('scheduling', () => {
clearInterval(reporter.scheduling.cleanScheduleHistoryIntervalTimer)
reporter.scheduling.stop()
})
}
{
"name": "jsreport-scheduling",
"version": "2.4.0",
"version": "2.5.0",
"description": "jsreport extension for scheduling background rendering jobs",

@@ -44,9 +44,9 @@ "scripts": {

"eslint-config-standard-jsx": "5.0.0",
"eslint-plugin-babel": "5.3.0",
"eslint-plugin-babel": "5.3.1",
"in-publish": "2.0.1",
"jsreport-authentication": "2.5.0",
"jsreport-authentication": "2.6.0",
"jsreport-authorization": "2.4.0",
"jsreport-core": "2.9.0",
"jsreport-reports": "2.4.0",
"jsreport-studio-dev": "1.5.0",
"jsreport-core": "2.10.0",
"jsreport-reports": "2.5.0",
"jsreport-studio-dev": "1.6.0",
"jsreport-templates": "2.4.0",

@@ -53,0 +53,0 @@ "lodash": "4.17.15",

@@ -5,3 +5,3 @@ import React, { Component } from 'react'

export default class DownloadButton extends Component {
class DownloadButton extends Component {
download () {

@@ -24,5 +24,2 @@ if (ScheduleEditor.ActiveReport) {

DownloadButton.propTypes = {
tab: React.PropTypes.object,
onUpdate: React.PropTypes.func.isRequired
}
export default DownloadButton

@@ -8,3 +8,4 @@ import React, { Component } from 'react'

let _activeReport
export default class ScheduleEditor extends Component {
class ScheduleEditor extends Component {
constructor () {

@@ -208,5 +209,2 @@ super()

ScheduleEditor.propTypes = {
entity: React.PropTypes.object.isRequired,
onUpdate: React.PropTypes.func.isRequired
}
export default ScheduleEditor

@@ -40,19 +40,14 @@ import React, { Component } from 'react'

componentWillMount () {
componentDidMount () {
this.normalizeUIState(this.props.entity)
}
componentDidMount () {
this.removeInvalidTemplateReferences()
}
componentWillReceiveProps (nextProps) {
componentDidUpdate (prevProps) {
// when component changes because another schedule is selected
// or when saving a new schedule
if (this.props.entity._id !== nextProps.entity._id) {
this.normalizeUIState(nextProps.entity)
if (prevProps.entity._id !== this.props.entity._id) {
this.normalizeUIState(this.props.entity)
}
}
componentDidUpdate () {
this.removeInvalidTemplateReferences()

@@ -59,0 +54,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