New_Micro_Learning/backend/app/Modules/Analytics/Jobs/ProcessLearningEvent.php

30 خطوط
821 B
PHP

<?php
namespace App\Modules\Analytics\Jobs;
use App\Modules\Analytics\Application\AnalyticsProjectionService;
use App\Modules\Learner\Domain\LearningEvent;
use App\Modules\Monitoring\Application\MonitoringEngine;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
final class ProcessLearningEvent implements ShouldQueue
{
use Queueable;
public int $tries = 3;
public function __construct(public readonly string $eventId)
{
$this->onQueue('analytics');
}
public function handle(AnalyticsProjectionService $analytics, MonitoringEngine $monitoring): void
{
$event = LearningEvent::query()->findOrFail($this->eventId);
if ($analytics->process($event)) {
$monitoring->refresh($event->organization_id);
}
}
}