23 lines
1.1 KiB
PHP
23 lines
1.1 KiB
PHP
<?php
|
|
|
|
use App\Services\InvestmentCatalogue;
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
require __DIR__.'/../vendor/autoload.php';
|
|
$app = require __DIR__.'/../bootstrap/app.php';
|
|
$app->make(Kernel::class)->bootstrap();
|
|
if (! $app->environment('local', 'testing') || DB::connection()->getDriverName() !== 'pgsql') {
|
|
throw new RuntimeException('Local/testing PostgreSQL required.');
|
|
}
|
|
$report = DB::transaction(function () {
|
|
DB::statement('SET TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ ONLY');
|
|
$map = app(InvestmentCatalogue::class)->map([]);
|
|
|
|
return ['generated_at' => date(DATE_ATOM), 'published_opportunities' => $map['matched_count'],
|
|
'georeferenced' => $map['georeferenced_count'], 'complete' => $map['complete'], 'truncated' => $map['truncated'],
|
|
'unlocated' => $map['unlocated'], 'geo_geometries' => DB::table('geo_geometries')->whereNull('deleted_at')->count(),
|
|
'zone_geometries' => DB::table('investment_zone_geometries')->count()];
|
|
});
|
|
echo json_encode($report, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR).PHP_EOL;
|