statistic wip

This commit is contained in:
salam committed 2026-04-29 19:00:46 +02:00
1 parent 01a3f41ec0
commit d6620fb0a1
10 files changed
+408 -333

No files matched your search

-71
View File
@@ -1,71 +0,0 @@
<?php
namespace App\Actions\Statistics;
use App\Models\StatistikoEvent;
class EventData
{
public static function get($filter)
{
$league_id = (int) $filter['league_id'] ?? 0;
$team_id = (int) $filter['team_id'] ?? 0;
if (! $league_id) {
return [];
}
if (! $team_id) {
return [];
}
switch ($filter['team_position']) {
case 'home':
$res = StatistikoEvent::where('league_id', $league_id)->where('home_id', '=', $team_id)->get();
break;
case 'away':
$res = StatistikoEvent::where('league_id', $league_id)->where('away_id', '=', $team_id)->get();
break;
default:
$res = StatistikoEvent::where('league_id', $league_id)
->where(function ($query) use ($team_id) {
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
})->get();
break;
}
$datasets = [];
$labels = [];
foreach ($res as $value) {
$labels[] = $value['starttime']->format('d. M.y');
$tmp = [];
$tmp['crd_a'] = (int) $value['crd_a'];
$tmp['crd_h'] = (int) $value['crd_h'];
$tmp['crn_a'] = (int) $value['crn_a'];
$tmp['crn_h'] = (int) $value['crn_h'];
$tmp['fls_a'] = (int) $value['fls_a'];
$tmp['fls_h'] = (int) $value['fls_h'];
$tmp['gls_a'] = (int) $value['gls_a'];
$tmp['gls_h'] = (int) $value['gls_h'];
$tmp['ofs_a'] = (int) $value['ofs_a'];
$tmp['ofs_h'] = (int) $value['ofs_h'];
$tmp['snt_a'] = (int) $value['snt_a'];
$tmp['snt_h'] = (int) $value['snt_h'];
$tmp['tsh_a'] = (int) $value['tsh_a'];
$tmp['tsh_h'] = (int) $value['tsh_h'];
$tmp['exp_handicap'] = (float) $value['exp_handicap'];
$tmp['exp_total'] = (float) $value['exp_total'];
$tmp['exp_away'] = (float) $value['expgoalsaway_value'];
$tmp['exp_home'] = (float) $value['expgoalshome_value'];
$datasets[] = $tmp;
}
return ['lables' => $labels, 'datasets' => $datasets];
}
}
+85
View File
@@ -0,0 +1,85 @@
<?php
namespace App\Actions\Statistics;
use App\Models\StatistikoEvent;
class LoadEvents
{
public static function load($filter)
{
$league_id = (int) $filter['league_id'] ?? 0;
$team_id = (int) $filter['team_id'] ?? 0;
if (! $league_id) {
return [];
}
if (! $team_id) {
return [];
}
switch ($filter['team_position']) {
case 'home':
$res = StatistikoEvent::where('league_id', $league_id)->where('home_id', '=', $team_id)->get();
break;
case 'away':
$res = StatistikoEvent::where('league_id', $league_id)->where('away_id', '=', $team_id)->get();
break;
default:
$res = StatistikoEvent::where('league_id', $league_id)
->where(function ($query) use ($team_id) {
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
})->get();
break;
}
$datasets = [];
$labels = [];
foreach ($res as $value) {
$labels[] = $value['starttime']->format('d. M.y');
// $tmp['exp_handicap'] = (float) $value['exp_handicap'];
// $tmp['exp_total'] = (float) $value['exp_total'];
// $tmp['exp_away'] = (float) $value['expgoalsaway_value'];
// $tmp['exp_home'] = (float) $value['expgoalshome_value'];
switch ($filter['statistic_type']) {
case 'gls':
$tmp['gls_a'] = (int) $value['gls_a'];
$tmp['gls_h'] = (int) $value['gls_h'];
break;
case 'crn':
$tmp['crn_a'] = (int) $value['crn_a'];
$tmp['crn_h'] = (int) $value['crn_h'];
break;
case 'fls':
$tmp['fls_a'] = (int) $value['fls_a'];
$tmp['fls_h'] = (int) $value['fls_h'];
break;
case 'ofs':
$tmp['ofs_a'] = (int) $value['ofs_a'];
$tmp['ofs_h'] = (int) $value['ofs_h'];
break;
case 'crd':
$tmp['crd_a'] = (int) $value['crd_a'];
$tmp['crd_h'] = (int) $value['crd_h'];
break;
case 'snt':
$tmp['snt_a'] = (int) $value['snt_a'];
$tmp['snt_h'] = (int) $value['snt_h'];
break;
case 'tsh':
$tmp['tsh_a'] = (int) $value['tsh_a'];
$tmp['tsh_h'] = (int) $value['tsh_h'];
break;
}
$datasets[] = $tmp;
}
return ['lables' => $labels, 'datasets' => $datasets];
}
}
+1 -37
View File
@@ -4,41 +4,5 @@ namespace App\Actions\Statistics;
class StatisticEvents
{
public static function load($filter)
{
$data = EventData::get($filter);
if (! $data) {
return [];
}
return [];
dd($data);
/*
"team_position" => "away"
"similar_past_matches" => "none"
"statistic_type" => "none"
"accuracy" => 0.5
"league_id" => "87"
"team_id" => null
"startDate" => null
"endDate" => null
"palyer_id" => null
'sport_id',
'league_id',
'home_id',
'away_id',
'starttime',
*/
// $res = StatistikoEvent::where('league_id', $league_id)->get();
// $result = DB::connection('mongodb')
// ->table('movies')
// ->where('league_id', $league_id)
// ->orWhere('home_id', $home_id)
// ->get();
}
public static function load($filter) {}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Actions\Statistics;
class StatisticType
{
protected static array $types = [
'gls' => 'Goals',
'crn' => 'Corner',
'fls' => 'Fouls commited',
'ofs' => 'Offside',
'crd' => 'Cards',
'snt' => 'Shot on target',
'tsh' => 'Total shots',
];
public static function get($filter): string
{
$tmp = $filter['statistic_type'] ?? 'none';
if (isset(self::$types[$tmp])) {
return self::$types[$tmp];
}
return 'Goals';
}
}