messages implemented
This commit is contained in:
36
app/Jobs/RecomputeUserStatsJob.php
Normal file
36
app/Jobs/RecomputeUserStatsJob.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Services\UserStatsService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
/**
|
||||
* Recomputes user_statistics for a batch of user IDs.
|
||||
* Dispatched by RecomputeUserStatsCommand when --queue is set.
|
||||
*/
|
||||
class RecomputeUserStatsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
public int $tries = 2;
|
||||
public int $timeout = 300;
|
||||
|
||||
/**
|
||||
* @param array<int> $userIds
|
||||
*/
|
||||
public function __construct(public readonly array $userIds) {}
|
||||
|
||||
public function handle(UserStatsService $statsService): void
|
||||
{
|
||||
foreach ($this->userIds as $userId) {
|
||||
$statsService->recomputeUser((int) $userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user