Aplicar Pint e formatação de frontend; delimitar o âmbito do lint
Só formatação automática (pint, vp check --fix), sem alterar comportamento. Excluídos da formatação os registos e artefactos com bytes fixos: docs/, integrations/, storage/, tmp/, output/, resources/data/, tests/Fixtures/, compras-release.json e AGENTS*.md. Scripts operacionais, integrations e auxiliares de teste ficam fora do lint (usam new Function; limpeza na fase 2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,16 +1,41 @@
|
||||
<?php
|
||||
$root=realpath((string)getenv('STOCK_RECEIPT_ROOT'));$file=realpath($argv[1]??'');
|
||||
if(!$root||!$file||dirname($file)!==$root)throw new RuntimeException('Unexpected private worker');
|
||||
require getcwd().'/vendor/autoload.php';$app=require getcwd().'/bootstrap/app.php';$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
$db=Illuminate\Support\Facades\DB::connection();$i=$db->selectOne("SELECT current_database() AS name,current_user AS role,current_setting('cluster_name') AS cluster");
|
||||
if(!preg_match('/^compras_receipts_test_([a-f0-9]{12})$/D',$i->name,$m)||$i->role!=='stock_receipt_qa_'.$m[1]||$i->cluster!=='sgf_modular_regression_'.getenv('SGF_ISOLATED_REGRESSION_RUN'))throw new RuntimeException('Wrong receipt worker database');
|
||||
$input=json_decode(file_get_contents($file),true,512,JSON_THROW_ON_ERROR);
|
||||
$db->select("SELECT set_config('application_name',?,false)",[$input['application']]);$db->statement("SET lock_timeout='8s'");$db->statement("SET statement_timeout='12s'");
|
||||
$actor=App\Models\User::findOrFail($input['actor']);auth()->guard()->setUser($actor);
|
||||
file_put_contents($file.'.ready','ready');
|
||||
$start=hrtime(true);
|
||||
try{$receipt=app(App\Services\ReceiptWorkflow::class)->confirm($actor,App\Models\PurchaseOrder::findOrFail($input['order']),$input['payload']);
|
||||
$result=['status'=>200,'receipt_id'=>$receipt->id];
|
||||
}catch(Illuminate\Validation\ValidationException){$result=['status'=>422];}
|
||||
catch(Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $e){$result=['status'=>$e->getStatusCode()];}
|
||||
$result['elapsed_ms']=round((hrtime(true)-$start)/1e6,3);file_put_contents($file.'.result',json_encode($result,JSON_THROW_ON_ERROR));
|
||||
|
||||
use App\Models\PurchaseOrder;
|
||||
use App\Models\User;
|
||||
use App\Services\ReceiptWorkflow;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
||||
$root = realpath((string) getenv('STOCK_RECEIPT_ROOT'));
|
||||
$file = realpath($argv[1] ?? '');
|
||||
if (! $root || ! $file || dirname($file) !== $root) {
|
||||
throw new RuntimeException('Unexpected private worker');
|
||||
}
|
||||
require getcwd().'/vendor/autoload.php';
|
||||
$app = require getcwd().'/bootstrap/app.php';
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
$db = DB::connection();
|
||||
$i = $db->selectOne("SELECT current_database() AS name,current_user AS role,current_setting('cluster_name') AS cluster");
|
||||
if (! preg_match('/^compras_receipts_test_([a-f0-9]{12})$/D', $i->name, $m) || $i->role !== 'stock_receipt_qa_'.$m[1] || $i->cluster !== 'sgf_modular_regression_'.getenv('SGF_ISOLATED_REGRESSION_RUN')) {
|
||||
throw new RuntimeException('Wrong receipt worker database');
|
||||
}
|
||||
$input = json_decode(file_get_contents($file), true, 512, JSON_THROW_ON_ERROR);
|
||||
$db->select("SELECT set_config('application_name',?,false)", [$input['application']]);
|
||||
$db->statement("SET lock_timeout='8s'");
|
||||
$db->statement("SET statement_timeout='12s'");
|
||||
$actor = User::findOrFail($input['actor']);
|
||||
auth()->guard()->setUser($actor);
|
||||
file_put_contents($file.'.ready', 'ready');
|
||||
$start = hrtime(true);
|
||||
try {
|
||||
$receipt = app(ReceiptWorkflow::class)->confirm($actor, PurchaseOrder::findOrFail($input['order']), $input['payload']);
|
||||
$result = ['status' => 200, 'receipt_id' => $receipt->id];
|
||||
} catch (ValidationException) {
|
||||
$result = ['status' => 422];
|
||||
} catch (HttpExceptionInterface $e) {
|
||||
$result = ['status' => $e->getStatusCode()];
|
||||
}
|
||||
$result['elapsed_ms'] = round((hrtime(true) - $start) / 1e6, 3);
|
||||
file_put_contents($file.'.result', json_encode($result,JSON_THROW_ON_ERROR));
|
||||
|
||||
Reference in New Issue
Block a user