Skip to content

Commit

Permalink
feature: purge process immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
rolu01 committed Nov 29, 2023
1 parent 3e50d7a commit bdb44a7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Each process that should be purged needs the following tags:
* `purge:{hours}:{status}:{type}` - This is the part where you specify when and how a process should be purged. `status` is a list of statuses that is separated with a comma.

> Note: The hours is calculated by the enddate. This means that processes missing enddate will not be purged.
> Note: Setting `hours` to `0` will purge the process immediately.
Purge types:

Expand All @@ -32,11 +33,12 @@ Purge types:

### Examples

* `purge:24:Completed` - Full purge process after 24 hours if the status is Completed
* `purge:1:Completed,Stopped` - Full purge process after 1 hour if the status is Completed or Stopped
* `purge:168:Stopped` - Full purge process after 1 week if the status is Stopped
* `purge:2190:Completed,Stopped:full` - Full purge process after 3 months if the status is Completed or Stopped
* `purge:48:Completed,Stopped:data` - Partial purge process after 48 hours if the status is Completed or Stopped
* `purge:0:Completed` - Delete the process immediately if the status is Completed
* `purge:24:Completed` - Delete the process after 24 hours if the status is Completed
* `purge:1:Completed,Stopped` - Delete the process after 1 hour if the status is Completed or Stopped
* `purge:168:Stopped` - Delete the process after 1 week if the status is Stopped
* `purge:2190:Completed,Stopped:full` - Delete the process after 3 months if the status is Completed or Stopped
* `purge:48:Completed,Stopped:data` - Partial (delete data) purge process after 48 hours if the status is Completed or Stopped

## Deploy

Expand Down
30 changes: 17 additions & 13 deletions onify-purge-processes.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1l06257" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.16.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.19.0">
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1l06257" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.17.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.19.0">
<bpmn:process id="onify-purge-processes" name="Purge processes in Onify" isExecutable="true">
<bpmn:endEvent id="end" name="Finished purging processes">
<bpmn:extensionElements>
Expand Down Expand Up @@ -164,6 +164,10 @@ next();</camunda:script>
next(null, false);
}

if (environment.output.purgeSettings.timer == 0) {
next(null, true);
}

const currentDateTime = new Date();
const hoursDiff = (currentDateTime - new Date(environment.variables.content.input.process.enddate)) / 3600000;

Expand Down Expand Up @@ -357,12 +361,6 @@ next();</camunda:script>
<dc:Bounds x="280" y="300" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_018jj10_di" bpmnElement="endPurgeProcess" bioc:stroke="#831311" bioc:fill="#ffcdd2" color:background-color="#ffcdd2" color:border-color="#831311">
<dc:Bounds x="2332" y="322" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="2314" y="365" width="72" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_133813l_di" bpmnElement="loopPurgeTags" isExpanded="true">
<dc:Bounds x="470" y="80" width="1760" height="550" />
<bpmndi:BPMNLabel />
Expand All @@ -377,6 +375,12 @@ next();</camunda:script>
<dc:Bounds x="770" y="200" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_1xnzox0" bpmnElement="endDeleted" bioc:stroke="#831311" bioc:fill="#ffcdd2" color:background-color="#ffcdd2" color:border-color="#831311">
<dc:Bounds x="1932" y="222" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1911" y="265" width="80" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_1v5o90k" bpmnElement="Gateway_0bgqho1" isMarkerVisible="true">
<dc:Bounds x="935" y="215" width="50" height="50" />
<bpmndi:BPMNLabel>
Expand Down Expand Up @@ -423,12 +427,6 @@ next();</camunda:script>
<dc:Bounds x="1900" y="320" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_1xnzox0" bpmnElement="endDeleted" bioc:stroke="#831311" bioc:fill="#ffcdd2" color:background-color="#ffcdd2" color:border-color="#831311">
<dc:Bounds x="1932" y="222" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="1911" y="265" width="80" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="BPMNShape_05x7xn8" bpmnElement="Event_0fgzkg5">
<dc:Bounds x="1782" y="222" width="36" height="36" />
<bpmndi:BPMNLabel>
Expand Down Expand Up @@ -508,6 +506,12 @@ next();</camunda:script>
<di:waypoint x="1818" y="240" />
<di:waypoint x="1932" y="240" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_018jj10_di" bpmnElement="endPurgeProcess" bioc:stroke="#831311" bioc:fill="#ffcdd2" color:background-color="#ffcdd2" color:border-color="#831311">
<dc:Bounds x="2332" y="322" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="2314" y="365" width="72" height="27" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_1a86zm9_di" bpmnElement="TextAnnotation_1a86zm9">
<dc:Bounds x="210" y="110" width="150" height="40" />
<bpmndi:BPMNLabel />
Expand Down

0 comments on commit bdb44a7

Please sign in to comment.