test refactoring

This commit is contained in:
Čarodej
2022-01-24 09:25:32 +01:00
parent 3677e51c8f
commit 87dbcbceb8
7 changed files with 147 additions and 130 deletions

View File

@@ -1,5 +1,4 @@
<?php
namespace Domain\Admin\Controllers\Dashboard;
use ByteUnits\Metric;
@@ -66,13 +65,13 @@ class GetDashboardDataController extends Controller
->groupBy('created_at')
->get();
$upload = $trafficRecords->map(fn($record) => [
$upload = $trafficRecords->map(fn ($record) => [
'created_at' => format_date($record->created_at, '%d. %B'),
'percentage' => intval($trafficRecords->max('upload')) !== 0 ? round(($record->upload / $trafficRecords->max('upload')) * 100, 2) : 0,
'amount' => Metric::bytes($record->upload)->format(),
]);
$download = $trafficRecords->map(fn($record) => [
$download = $trafficRecords->map(fn ($record) => [
'created_at' => format_date($record->created_at, '%d. %B'),
'percentage' => intval($trafficRecords->max('download')) !== 0 ? round(($record->download / $trafficRecords->max('download')) * 100, 2) : 0,
'amount' => Metric::bytes($record->download)->format(),