Added log for query execution time #1140

Merged
jothi merged 1 commits from ranjith-dev into master 2026-09-30 10:45:50 +00:00

View File

@@ -6,6 +6,7 @@ use App\Exports\ProductionPlanExport;
use App\Models\ProductionPlan;
use App\Models\ProductionQuantity;
use App\Models\QualityValidation;
use Illuminate\Support\Facades\Log;
use Livewire\Component;
use Carbon\Carbon;
use DB;
@@ -29,7 +30,6 @@ class ProductionTargetPlan extends Component
protected $listeners = [
'loadData' => 'loadProductionData',
'loadData1' => 'exportProductionData',
'loadDataMonthly' => 'loadMonthlyPlan',
];
public function getMonthDates($month, $year)
@@ -468,6 +468,8 @@ class ProductionTargetPlan extends Component
$dates = $this->getMonthDates($month, $year);
$this->dates = $dates;
$start = microtime(true);
$plans = ProductionPlan::query()
->join('items', 'items.id', '=', 'production_plans.item_id')
->join('lines', 'lines.id', '=', 'production_plans.line_id')
@@ -493,6 +495,8 @@ class ProductionTargetPlan extends Component
)
->get();
Log::info('Plans: ' . ((microtime(true) - $start) * 1000) . ' ms');
$leaveDates = [];
if ($plans->isNotEmpty() && $plans[0]->leave_dates) {
@@ -501,6 +505,8 @@ class ProductionTargetPlan extends Component
$this->leaveDates = $leaveDates;
$start = microtime(true);
$producedData = QualityValidation::selectRaw("
quality_validations.plant_id,
quality_validations.line_id,
@@ -530,6 +536,8 @@ class ProductionTargetPlan extends Component
)
->map(fn($group) => $group->keyBy('prod_date'));
Log::info('Quality: ' . ((microtime(true) - $start) * 1000) . ' ms');
$records = [];
foreach ($plans as $plan) {