Files
Investidor-V2/outputs/investmoz-editorial-QA-20261018/minimize.py
T
nala cf003c8623
tests / ci (push) Canceled after 0s
versao nrgocios 4
2026-10-18 15:57:06 +02:00

26 lines
2.8 KiB
Python

from pathlib import Path
r=Path.cwd();q=Path('C:/Users/macbook/.config/investmoz/editorial-QA-20261018/source')
changes={
'app/Http/Controllers/PortalManagementController.php':[("'is_active' => ['required', 'boolean'],","'is_active' => ['required', 'boolean'],\n 'editorial_published' => ['required', 'boolean'],"),(" $data = $request->validate($rules);"," $data = $request->validate($rules);\n if ($resource === 'sectors') {\n $data['published_at'] = $data['editorial_published'] ? ($record->published_at ?? now()) : null;\n unset($data['editorial_published']);\n }")],
'app/Http/Controllers/PortalServicesController.php':[("'downloadUrl' => route('services.download', ['id' => $id]),","'downloadUrl' => route('services.download', ['id' => $id]),\n 'articleUrl' => Schema::hasColumn('portal_resources','editorial_content') && DB::table('portal_resources')->where('id',$id)->whereNotNull('editorial_content')->exists() ? '/artigos/'.$id : null,")],
'app/Http/Controllers/PublicPortalController.php':[("Sector::where('slug', $slug)->where('is_active', true)->firstOrFail()","Sector::where('slug', $slug)->where('is_active', true)->whereNotNull('published_at')->firstOrFail()")],
'app/Services/InvestmentCatalogue.php':[("Sector::choices()->orderBy('name')","Sector::choices()->whereNotNull('published_at')->orderBy('name')")],
'app/Services/OpportunityClassification.php':[("$this->targets($kind)->orderBy($label)->get(['id', $label.' as label'])","$this->targets($kind)->when($kind === 'sector', fn ($q) => $q->whereNotNull('published_at'))->orderBy($label)->get(['id', $label.' as label'])")],
'app/Services/LegacyContent.php':[(" $localHtml = $this->localLinks($this->sanitize($source['content_html']));",''' $localHtml = $this->localLinks($this->sanitize($source['content_html']));
$editorial = \\Illuminate\\Support\\Facades\\Schema::hasColumn('portal_resources', 'editorial_content')
? DB::table('portal_resources')->where('id', $row->resource_id)->value('editorial_content') : null;
if ($editorial) {
$adaptation = json_decode($editorial, true, 64, JSON_THROW_ON_ERROR);
$localHtml = implode('', array_map(fn ($p) => '<p>'.nl2br(e($p)).'</p>', preg_split('/\\n\\s*\\n/', $adaptation['body'])));
$source['title'] = $row->title;
if (!empty($adaptation['image_resource_id'])) {
$image = $this->publicResources()->where('r.id', $adaptation['image_resource_id'])->whereIn('d.media_type', ['image/png', 'image/jpeg', 'image/webp'])->first();
}
}''')]
}
for n, pairs in changes.items():
s=(r/n).read_text('utf8')
for a,b in pairs:assert a in s,n;s=s.replace(a,b,1)
(q/n).write_text(s,'utf8')
print('Only semantic deltas retained in existing PHP files; original formatting preserved')