add test batches

This commit is contained in:
root
2026-06-08 23:45:55 -04:00
parent c792b8be05
commit 8d4d610b82
1480 changed files with 22587 additions and 10762 deletions
@@ -19,7 +19,7 @@ use Illuminate\Support\Facades\Log;
*/
class PromotionReminderService
{
/** @var (callable(int, string, string, array):void)|null */
/** @var (callable(int $userId, string $title, string $body, array $channels):void)|null */
private $dispatcher;
public function __construct(
@@ -40,7 +40,7 @@ class PromotionReminderService
?string $message = null,
array $channels = ['in_app', 'email']
): PromotionReminderLog {
if (! in_array($reminderType, PromotionReminderLog::ALLOWED_TYPES, true)) {
if (!in_array($reminderType, PromotionReminderLog::ALLOWED_TYPES, true)) {
$reminderType = PromotionReminderLog::TYPE_MANUAL;
}
@@ -53,7 +53,7 @@ class PromotionReminderService
'%s is eligible for promotion to %s.%s Please complete enrollment as soon as possible.',
$studentName ?: 'Your child',
$level,
$deadline ? ' Deadline: '.$deadline.'.' : ''
$deadline ? ' Deadline: ' . $deadline . '.' : ''
);
$finalSubject = $subject ?: $defaultSubject;
@@ -83,7 +83,7 @@ class PromotionReminderService
$this->dispatch((int) $record->parent_id, $finalSubject, $finalMessage, $channels);
}
if (! $record->parent_notified_at) {
if (!$record->parent_notified_at) {
$record->parent_notified_at = now();
$record->save();
$this->audit->logParentNotified($record, $userId, $reminderType);
@@ -118,7 +118,6 @@ class PromotionReminderService
$type = $this->resolveReminderType($record, $now);
if ($type === null) {
$skipped++;
continue;
}
$alreadySent = PromotionReminderLog::query()
@@ -127,7 +126,6 @@ class PromotionReminderService
->exists();
if ($alreadySent) {
$skipped++;
continue;
}
try {
@@ -179,24 +177,22 @@ class PromotionReminderService
if ($elapsedSeconds * 2 >= $totalSeconds) {
return PromotionReminderLog::TYPE_HALFWAY;
}
return PromotionReminderLog::TYPE_FIRST;
}
private function studentName(StudentPromotionRecord $record): ?string
{
$student = Student::query()->find($record->student_id);
if (! $student) {
if (!$student) {
return null;
}
$name = trim((string) ($student->firstname ?? '').' '.(string) ($student->lastname ?? ''));
$name = trim((string) ($student->firstname ?? '') . ' ' . (string) ($student->lastname ?? ''));
return $name !== '' ? $name : null;
}
private function dispatch(int $userId, string $subject, string $message, array $channels): void
{
if (! $this->dispatcher) {
if (!$this->dispatcher) {
return;
}
try {