Commit 737d470e authored by Mahmoud Aglan's avatar Mahmoud Aglan

Guard enforce-thresholds command with auto_suspend_on_threshold check

This was the THIRD auto-suspend mechanism (alongside send-alerts and
the real-time listener). It directly wrote status='suspended' without
going through the event/listener. Now all three paths respect the
same opt-in setting.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 660d4a19
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
use App\Domain\Attendance\Enums\AttendanceStatus; use App\Domain\Attendance\Enums\AttendanceStatus;
use App\Domain\Attendance\Models\AttendanceRecord; use App\Domain\Attendance\Models\AttendanceRecord;
use App\Domain\Participant\Models\Participant; use App\Domain\Participant\Models\Participant;
use App\Domain\Shared\Services\SettingsService;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
...@@ -16,8 +17,13 @@ class EnforceAttendanceThresholds extends Command ...@@ -16,8 +17,13 @@ class EnforceAttendanceThresholds extends Command
private const DEFAULT_MAX_CONSECUTIVE_ABSENCES = 5; private const DEFAULT_MAX_CONSECUTIVE_ABSENCES = 5;
private const DEFAULT_MIN_ATTENDANCE_PERCENT = 75; private const DEFAULT_MIN_ATTENDANCE_PERCENT = 75;
public function handle(): int public function handle(SettingsService $settings): int
{ {
if (!(bool) $settings->get('auto_suspend_on_threshold', false)) {
$this->info('Auto-suspend is disabled (auto_suspend_on_threshold = false). Skipping.');
return self::SUCCESS;
}
$this->checkConsecutiveAbsences(); $this->checkConsecutiveAbsences();
$this->checkAttendancePercentage(); $this->checkAttendancePercentage();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment