server-socket-framework-jps
Advanced tools
Comparing version 1.1.0-2 to 1.1.0-3
@@ -14,4 +14,4 @@ import { JobConfig, JobError, JobListener, JobStatus } from "./Job"; | ||
addListener(listener: JobListener): void; | ||
protected calculateNextExecuteTime(config: JobConfig): number; | ||
protected calculateNextExecuteTime(config: JobConfig, isAboutToRun?: boolean): number; | ||
addJob(config: JobConfig): void; | ||
} |
@@ -39,3 +39,3 @@ "use strict"; | ||
// execute the job | ||
queueItem.nextRunTime = this.calculateNextExecuteTime(queueItem.config); | ||
queueItem.nextRunTime = this.calculateNextExecuteTime(queueItem.config, true); | ||
logger(`Executing job ${queueItem.config.name}, next execution time will be ${(0, moment_1.default)(queueItem.nextRunTime, 'YYYYMMDDHHmm').format('DD/MM/YYYY HH:mm')}`); | ||
@@ -52,10 +52,15 @@ queueItem.config.job.executeJob((0, uuid_1.v4)(), this.jobCallback); | ||
} | ||
calculateNextExecuteTime(config) { | ||
calculateNextExecuteTime(config, isAboutToRun = false) { | ||
let nextExecuteTime = 0; | ||
if (config.isDailyJob) { | ||
const now = parseFloat((0, moment_1.default)().format('YYYYMMDDHHmm')); | ||
nextExecuteTime = parseFloat((0, moment_1.default)(`${(0, moment_1.default)().format('YYYYMMDD')}${config.executeDailyAtTime}`, 'YYYYMMDDHHmm').format('YYYYMMDDHHmm')); | ||
if (nextExecuteTime < now) { | ||
if (isAboutToRun) { | ||
nextExecuteTime = parseFloat((0, moment_1.default)(`${(0, moment_1.default)().add(1, 'day').format('YYYYMMDD')}${config.executeDailyAtTime}`, 'YYYYMMDDHHmm').format('YYYYMMDDHHmm')); | ||
} | ||
else { | ||
const now = parseFloat((0, moment_1.default)().format('YYYYMMDDHHmm')); | ||
nextExecuteTime = parseFloat((0, moment_1.default)(`${(0, moment_1.default)().format('YYYYMMDD')}${config.executeDailyAtTime}`, 'YYYYMMDDHHmm').format('YYYYMMDDHHmm')); | ||
if (nextExecuteTime < now) { | ||
nextExecuteTime = parseFloat((0, moment_1.default)(`${(0, moment_1.default)().add(1, 'day').format('YYYYMMDD')}${config.executeDailyAtTime}`, 'YYYYMMDDHHmm').format('YYYYMMDDHHmm')); | ||
} | ||
} | ||
} | ||
@@ -79,3 +84,3 @@ else { | ||
config: config, | ||
nextRunTime: this.calculateNextExecuteTime(config) | ||
nextRunTime: this.calculateNextExecuteTime(config, false) | ||
}; | ||
@@ -88,3 +93,3 @@ logger(`Adding daily job ${queueItem.config.name} to queue, next execution time will be ${(0, moment_1.default)(queueItem.nextRunTime, 'YYYYMMDDHHmm').format('DD/MM/YYYY HH:mm')}`); | ||
config: config, | ||
nextRunTime: this.calculateNextExecuteTime(config) | ||
nextRunTime: this.calculateNextExecuteTime(config, false) | ||
}; | ||
@@ -91,0 +96,0 @@ logger(`Adding job ${queueItem.config.name} to queue, next execution time will be ${(0, moment_1.default)(queueItem.nextRunTime, 'YYYYMMDDHHmm').format('DD/MM/YYYY HH:mm')}`); |
{ | ||
"name": "server-socket-framework-jps", | ||
"version": "1.1.0-2", | ||
"version": "1.1.0-3", | ||
"description": "A simple socket framework for persistent chat rooms and data messages", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78775
1098