Perbaikan Lanjutan Menu Simulasi Jabatan P2
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Remunerasi;
|
||||
|
||||
use App\Http\Controllers\Lainnya\SimulasiJabatan\SimulasiJabatanController;
|
||||
use App\Models\Verifikator\Periode;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class WarmSimulasiJabatanCacheCommand extends Command
|
||||
{
|
||||
protected $signature = 'simulasi-jabatan:warm-cache {periode?}';
|
||||
|
||||
protected $description = 'Pra-hitung & cache dataset menu Lainnya > Simulasi Jabatan agar halaman terbuka ringan';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
$periode = $this->argument('periode')
|
||||
? Periode::where('id_periode', $this->argument('periode'))->first()
|
||||
: Periode::where('status', true)->first();
|
||||
|
||||
if (! $periode) {
|
||||
$this->error('Periode tidak ditemukan.');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
$id = (int) $periode->id_periode;
|
||||
|
||||
Cache::forget(SimulasiJabatanController::datasetCacheKey($id));
|
||||
|
||||
$start = microtime(true);
|
||||
$rows = app(SimulasiJabatanController::class)->dataset($id);
|
||||
|
||||
$this->info(sprintf(
|
||||
'Periode %d: %d baris di-cache (%.1fs).',
|
||||
$id,
|
||||
$rows->count(),
|
||||
microtime(true) - $start
|
||||
));
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user