Skip to content

Commit 5875f22

Browse files
Implement EvaludateCasesRetention command
1 parent 4a87002 commit 5875f22

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace ProcessMaker\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use ProcessMaker\Jobs\EvaluateProcessRetentionJob;
7+
use ProcessMaker\Models\Process;
8+
9+
class EvaluateCaseRetention extends Command
10+
{
11+
/**
12+
* The name and signature of the console command.
13+
*
14+
* @var string
15+
*/
16+
protected $signature = 'cases:retention:evaluate';
17+
18+
/**
19+
* The console command description.
20+
*
21+
* @var string
22+
*/
23+
protected $description = 'Evaluate and delete cases past their retention period';
24+
25+
/**
26+
* Execute the console command.
27+
*/
28+
public function handle()
29+
{
30+
$this->info('Evaluating and deleting cases past their retention period');
31+
32+
Process::whereNotNull('properties->retention_period')->chunkById(100, function ($processes) {
33+
foreach ($processes as $process) {
34+
dispatch(new EvaluateProcessRetentionJob($process->id));
35+
}
36+
});
37+
38+
$this->info('Cases retention evaluation complete');
39+
}
40+
}

0 commit comments

Comments
 (0)