Форматирование

This commit is contained in:
brusnitsyn
2026-04-24 16:46:10 +09:00
parent fd0e6ee817
commit 63daa62888
87 changed files with 1380 additions and 791 deletions

View File

@@ -1,4 +1,5 @@
<?php
// app/Console/Commands/FillAverageBedDaysMetric.php
namespace App\Console\Commands;
@@ -9,7 +10,6 @@ use App\Models\Report;
use App\Services\ReportService;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class FillAverageBedDaysMetric extends Command
{
@@ -71,19 +71,21 @@ class FillAverageBedDaysMetric extends Command
if ($totalReports === 0) {
$this->warn('No reports found matching criteria.');
return 0;
}
$this->info("Found {$totalReports} reports to process");
// Confirm if large number
if ($totalReports > 1000 && !$this->confirm("Processing {$totalReports} reports may take a while. Continue?")) {
if ($totalReports > 1000 && ! $this->confirm("Processing {$totalReports} reports may take a while. Continue?")) {
$this->info('Command cancelled.');
return 0;
}
$force = $this->option('force');
$chunkSize = (int)$this->option('chunk');
$chunkSize = (int) $this->option('chunk');
// Progress bar
$bar = $this->output->createProgressBar($totalReports);
@@ -110,7 +112,7 @@ class FillAverageBedDaysMetric extends Command
} catch (\Exception $e) {
$errors++;
$this->warn("\nError processing report {$report->report_id}: " . $e->getMessage());
$this->warn("\nError processing report {$report->report_id}: ".$e->getMessage());
}
$bar->advance();
@@ -139,7 +141,7 @@ class FillAverageBedDaysMetric extends Command
$this->info('Sample of updated reports:');
// Get a sample of recently updated reports
$sampleQuery = Report::whereHas('metrikaResults', function($q) {
$sampleQuery = Report::whereHas('metrikaResults', function ($q) {
$q->where('rf_metrika_item_id', 18);
})
->orderBy('report_id', 'desc')
@@ -156,10 +158,11 @@ class FillAverageBedDaysMetric extends Command
$sampleQuery->where('rf_department_id', $departmentId);
}
$sample = $sampleQuery->get()->map(function($report) {
$sample = $sampleQuery->get()->map(function ($report) {
$metric = $report->metrikaResults
->where('rf_metrika_item_id', 18)
->first();
return [
'report_id' => $report->report_id,
'department' => $report->rf_department_id,
@@ -189,7 +192,7 @@ class FillAverageBedDaysMetric extends Command
->where('rf_metrika_item_id', 18)
->first();
if ($existingMetric && !$force) {
if ($existingMetric && ! $force) {
return 'skipped';
}
@@ -207,6 +210,7 @@ class FillAverageBedDaysMetric extends Command
],
['value' => 0]
);
return 'no_snapshots';
}