30 lines
1006 B
PHP
30 lines
1006 B
PHP
<?php
|
|
|
|
namespace App\Jobs\Release;
|
|
|
|
use App\Support\Release\ShadowComparisonRunner;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\File;
|
|
|
|
final class RunShadowComparisonJob implements ShouldQueue
|
|
{
|
|
use Dispatchable;
|
|
use InteractsWithQueue;
|
|
use Queueable;
|
|
use SerializesModels;
|
|
|
|
public function __construct(public readonly string $module = 'all') {}
|
|
|
|
public function handle(ShadowComparisonRunner $runner): void
|
|
{
|
|
$results = array_map(fn ($result): array => $result->toArray(), $runner->runAll());
|
|
$path = storage_path('app/generated/shadow-comparisons/job-'.$this->module.'-'.now()->format('Ymd-His').'.json');
|
|
File::ensureDirectoryExists(dirname($path));
|
|
File::put($path, json_encode(['results' => $results], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
|
}
|
|
}
|