handle some performance for app

This commit is contained in:
2026-06-03 21:52:37 +03:30
parent 08a1ff85b5
commit aea3cbbc6e
4 changed files with 90 additions and 10 deletions
+20 -8
View File
@@ -74,6 +74,11 @@ class ReportController extends Controller
}
public function upDownPrice()
{
return $this->buildUpDownPrices();
}
protected function buildUpDownPrices(): array
{
$feeSettings = Setting::whereIn('key', ['fee_single', 'buy_fee', 'sell_fee'])
->pluck('value', 'key');
@@ -121,6 +126,13 @@ class ReportController extends Controller
return ['sell' => $minP - $diffSell, 'buy' => $maxP + $diffBuy];
}
protected function appendUpPrices(array $payload): array
{
$payload['up'] = $this->buildUpDownPrices();
return $payload;
}
public function lastPrice()
{
$config = app(ConfigService::class);
@@ -145,7 +157,7 @@ class ReportController extends Controller
};
$zeroResponse = function () {
return [
return $this->appendUpPrices([
'sell' => 0,
'buy' => 0,
'price_last' => 0,
@@ -155,7 +167,7 @@ class ReportController extends Controller
'montzar' => 0,
'closed' => true,
'time' => now(),
];
]);
};
/*
@@ -356,7 +368,7 @@ class ReportController extends Controller
if ($priceValue <= 0) {
if (!$show_last_price) {
return [
return $this->appendUpPrices([
'sell' => 0,
'buy' => 0,
'price_last' => 0,
@@ -366,13 +378,13 @@ class ReportController extends Controller
'montzar' => $montzar_price ?? 0,
'closed' => true,
'time' => now(),
];
]);
}
$lastPrice = Price::latest()->first();
if (!$lastPrice || (float) $lastPrice->price <= 0) {
return [
return $this->appendUpPrices([
'sell' => 0,
'buy' => 0,
'price_last' => 0,
@@ -382,7 +394,7 @@ class ReportController extends Controller
'montzar' => $montzar_price ?? 0,
'closed' => true,
'time' => now(),
];
]);
}
$priceValue = (float) $lastPrice->price;
@@ -468,7 +480,7 @@ class ReportController extends Controller
$config->trackDailyPriceExtreme((float) $priceValue);
}
return [
return $this->appendUpPrices([
'sell' => $sell,
'buy' => $buy,
'price_last' => $priceLast,
@@ -478,7 +490,7 @@ class ReportController extends Controller
'montzar' => $montzar_price ?? 0,
'closed' => false,
'time' => now(),
];
]);
}
public function check()