@5minds/node-red-contrib-processcube
Advanced tools
Comparing version 1.6.0-process-instance-delete-hotfix-120ac3-m4vdm2ls to 1.6.0-process-instance-delete-hotfix-2fb3d7-m4vgglgi
{ | ||
"name": "@5minds/node-red-contrib-processcube", | ||
"version": "1.6.0-process-instance-delete-hotfix-120ac3-m4vdm2ls", | ||
"version": "1.6.0-process-instance-delete-hotfix-2fb3d7-m4vgglgi", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Node-RED nodes for ProcessCube", |
@@ -21,10 +21,22 @@ module.exports = function (RED) { | ||
const isHours = msg.payload.time_unit | ||
? msg.payload.time_unit.toLowerCase() === 'hours' | ||
: config.time_unit.toLowerCase() === 'hours'; | ||
const multiplier = isHours ? 1 : 24; | ||
// Gültige Werte für time_type | ||
const validTimeTypes = ['days', 'hours']; | ||
const timeType = msg.payload.time_type | ||
? msg.payload.time_type.toLowerCase() | ||
: config.time_type?.toLowerCase(); | ||
// time_type validieren | ||
if (!timeType || !validTimeTypes.includes(timeType)) { | ||
node.error(`Invalid time_type provided: ${timeType}. Allowed values are 'days' or 'hours'.`); | ||
return; | ||
} | ||
// Zeitmultiplikator berechnen | ||
const multiplier = timeType === 'hours' ? 1 : 24; | ||
node.log(`Time type: ${timeType}, multiplier: ${multiplier}`); | ||
const deletionDate = new Date(Date.now() - timeToUse * multiplier * 60 * 60 * 1000); | ||
node.log(`Errechnetes Datum: ${deletionDate}`); | ||
const modelId = msg.payload.processModelId?.trim() || config.modelid?.trim(); | ||
if (!modelId) { | ||
@@ -39,5 +51,6 @@ node.error('processModelId is not defined or empty.'); | ||
const result = await client.processInstances.query( | ||
{ processModelId: modelId, | ||
finishedBefore: deletionDate.toISOString(), | ||
state: ["finished", "error", "terminated"], | ||
{ | ||
processModelId: modelId, | ||
finishedBefore: deletionDate.toISOString(), | ||
state: ["finished", "error", "terminated"], | ||
}, | ||
@@ -44,0 +57,0 @@ { identity: node.engine.identity } |
Sorry, the diff of this file is not supported yet
515785
9873