initial
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Cron_Cleanup - daily retention purge. Removes only confirmed-delivered records
|
||||
* past the retention window, across both environments. Pending/failed are never
|
||||
* purged on a timer.
|
||||
*
|
||||
* @package ESP\Instanda
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ESP\Instanda;
|
||||
|
||||
final class Cron_Cleanup {
|
||||
|
||||
public static function run(): void {
|
||||
$days = (int) get_option('espinstanda_retention_days', 7);
|
||||
if ($days <= 0) {
|
||||
return; // retention disabled
|
||||
}
|
||||
|
||||
$store = new Transaction_Store();
|
||||
$deleted = 0;
|
||||
foreach ([Environment::Test, Environment::Live] as $env) {
|
||||
$deleted += $store->purge_delivered_older_than($days, $env);
|
||||
}
|
||||
|
||||
if ($deleted > 0) {
|
||||
Logger::debug("Retention purge removed {$deleted} delivered transaction(s) older than {$days} day(s).");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user