wip
This commit is contained in:
1 parent
188e873f8d
commit
25f8518773
2 files changed
+55
-10
No files matched your search
@@ -5,7 +5,6 @@ namespace App\Filament\Widgets\Data;
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class LoadEvents
|
||||
{
|
||||
@@ -93,28 +92,31 @@ class LoadEvents
|
||||
->orderBy('starttime', 'ASC')
|
||||
->get();
|
||||
|
||||
// dd($res);
|
||||
|
||||
if ($res == null) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// dd($res);
|
||||
|
||||
// $total = count($res);
|
||||
|
||||
Log::info($res);
|
||||
// Log::info($total);
|
||||
|
||||
$datasets = [];
|
||||
$labels = [];
|
||||
$labels_since = [];
|
||||
$results = ['w' => 0, 'd' => 0, 'l' => 0];
|
||||
|
||||
foreach ($res as $value) {
|
||||
|
||||
$labels[] = $value['starttime']->format('d.M.y');
|
||||
|
||||
if ($team_position == 'home') {
|
||||
switch ($value['result_code']) {
|
||||
case '1':
|
||||
$results['w']++;
|
||||
break;
|
||||
case 'x':
|
||||
$results['d']++;
|
||||
break;
|
||||
case '2':
|
||||
$results['l']++;
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($statistic_type) {
|
||||
case 'gls':
|
||||
@@ -141,6 +143,18 @@ class LoadEvents
|
||||
}
|
||||
} elseif ($team_position == 'away') {
|
||||
|
||||
switch ($value['result_code']) {
|
||||
case '1':
|
||||
$results['l']++;
|
||||
break;
|
||||
case 'x':
|
||||
$results['d']++;
|
||||
break;
|
||||
case '2':
|
||||
$results['w']++;
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($statistic_type) {
|
||||
case 'gls':
|
||||
$val = (int) $value['gls_a'];
|
||||
@@ -165,6 +179,25 @@ class LoadEvents
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch ($value['result_code']) {
|
||||
case '1':
|
||||
if ($team_id == $value['home_id']) {
|
||||
$results['w']++;
|
||||
} else {
|
||||
$results['l']++;
|
||||
}
|
||||
break;
|
||||
case 'x':
|
||||
$results['d']++;
|
||||
break;
|
||||
case '2':
|
||||
if ($team_id == $value['home_id']) {
|
||||
$results['l']++;
|
||||
} else {
|
||||
$results['w']++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch ($statistic_type) {
|
||||
case 'gls':
|
||||
@@ -235,6 +268,7 @@ class LoadEvents
|
||||
],
|
||||
'labels' => $labels,
|
||||
'description' => $description ?? '',
|
||||
'results' => $results,
|
||||
];
|
||||
|
||||
self::$last_query = $data;
|
||||
|
||||
@@ -13,6 +13,14 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
|
||||
protected ?string $pollingInterval = null;
|
||||
|
||||
public function getColumns(): int|array
|
||||
{
|
||||
return [
|
||||
'md' => 3,
|
||||
'xl' => 6,
|
||||
];
|
||||
}
|
||||
|
||||
protected function getStats(): array
|
||||
{
|
||||
$filters = $this->filters;
|
||||
@@ -50,6 +58,9 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
Stat::make('Number of events', $total),
|
||||
Stat::make('Average', round($summe / $total, 1)),
|
||||
Stat::make('Median', $median),
|
||||
Stat::make('Win', $data['results']['w']),
|
||||
Stat::make('Draw', $data['results']['d']),
|
||||
Stat::make('Lost', $data['results']['l']),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user