CI Feature / test (push) Successful in 4m41s
Der Registry-Test erlaubt bewusst Widgets, die nur aus einem Verweis bestehen (Anfrage: nur die Kennung eines Einstiegs) und kennt die neue Widget-Art. ADR-60, Beschreibung der Kommunikationsverwaltung, Rückfall und Migration in der Release-Vorbereitung. Der Browser meldet laufende Zustandsabfragen über aria-busy. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
44 lines
1.3 KiB
PHP
44 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Domain\Communication\CommunicationSettings;
|
|
use App\Domain\Communication\Inquiry;
|
|
use Illuminate\Console\Command;
|
|
|
|
/**
|
|
* Löscht Anfragen, die älter sind als die in „Kommunikation → Einstellungen“ gewählte Aufbewahrungsdauer. Ohne
|
|
* Aufbewahrungsdauer geschieht nichts. Mit --pretend wird nur gezählt.
|
|
*/
|
|
class PurgeInquiries extends Command
|
|
{
|
|
protected $signature = 'communication:purge {--pretend : Nur zählen, nichts löschen}';
|
|
|
|
protected $description = 'Löscht Anfragen nach Ablauf der Aufbewahrungsdauer (Einstellungen der Kommunikationsverwaltung)';
|
|
|
|
public function handle(): int
|
|
{
|
|
$months = CommunicationSettings::current()->retention_months;
|
|
|
|
if ($months === null || $months < 1) {
|
|
$this->info('Keine Aufbewahrungsdauer eingestellt; es wird nichts gelöscht.');
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
$query = Inquiry::query()->where('created_at', '<', now()->subMonths($months));
|
|
$count = $query->count();
|
|
|
|
if ($this->option('pretend')) {
|
|
$this->info("$count Anfragen wären älter als $months Monate.");
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
$query->delete();
|
|
$this->info("$count Anfragen gelöscht (älter als $months Monate).");
|
|
|
|
return self::SUCCESS;
|
|
}
|
|
}
|