mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
33 lines
721 B
PHP
33 lines
721 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\Mod;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class UpdateModDownloadsJob implements ShouldQueue
|
|
{
|
|
use Dispatchable;
|
|
use InteractsWithQueue;
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
/**
|
|
* Recalculate the total download counts for each mod.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
Mod::with('versions')->chunk(100, function ($mods): void {
|
|
foreach ($mods as $mod) {
|
|
$mod->calculateDownloads();
|
|
}
|
|
});
|
|
}
|
|
}
|