mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-12 20:20:41 -05:00
- Download counts were taking too long to calculate dynamically, so we're keeping track of a total count with observers and queued job. - Optimized the SQL used to order a mod listing by mod version update times.
28 lines
665 B
PHP
28 lines
665 B
PHP
<?php
|
|
|
|
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, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
/**
|
|
* Recalculate the total download counts for each mod.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
Mod::with('versions')->chunk(100, function ($mods) {
|
|
foreach ($mods as $mod) {
|
|
$mod->calculateDownloads();
|
|
}
|
|
});
|
|
}
|
|
}
|