From 01b62be635d595f65734221b14c07a54b9dd328e Mon Sep 17 00:00:00 2001 From: salam Date: Fri, 9 Oct 2026 18:16:10 +0200 Subject: [PATCH] min max for asp --- app/Filament/Pages/Statistic.php | 12 +++ .../Widgets/Boxes/ExpectationsTeam.php | 19 +++-- .../Boxes/Helper/ExpectationsMinMax.php | 79 +++++++++++++++++++ .../Charts/LoadEvents/LoadEventsQueryAll.php | 1 - 4 files changed, 102 insertions(+), 9 deletions(-) create mode 100644 app/Filament/Widgets/Boxes/Helper/ExpectationsMinMax.php diff --git a/app/Filament/Pages/Statistic.php b/app/Filament/Pages/Statistic.php index 8f434130..e8a96f39 100644 --- a/app/Filament/Pages/Statistic.php +++ b/app/Filament/Pages/Statistic.php @@ -229,6 +229,18 @@ class Statistic extends BaseDashboard $copystring .= implode(';', $row)."\n"; $row = []; $row = array_fill(0, 5, ''); + $row[] = 'Corner'; + $row[] = $data['crn']['home']; + $row[] = $data['crn']['away']; + $row[] = $data['crn_team']['home']; + $row[] = $data['crn_team']['away']; + $row[] = $data['crn_team_season']['home']; + $row[] = $data['crn_team_season']['away']; + $row[] = $data['crn_liga_season']['home']; + $row[] = $data['crn_liga_season']['away']; + $copystring .= implode(';', $row)."\n"; + $row = []; + $row = array_fill(0, 5, ''); $row[] = 'Fouls'; $row[] = $data['fls']['home']; $row[] = $data['fls']['away']; diff --git a/app/Filament/Widgets/Boxes/ExpectationsTeam.php b/app/Filament/Widgets/Boxes/ExpectationsTeam.php index 7f02dfaa..c87f254f 100644 --- a/app/Filament/Widgets/Boxes/ExpectationsTeam.php +++ b/app/Filament/Widgets/Boxes/ExpectationsTeam.php @@ -5,6 +5,7 @@ namespace App\Filament\Widgets\Boxes; use App\Filament\Widgets\Boxes\Helper\ExpectationCalculationMethodA; use App\Filament\Widgets\Boxes\Helper\ExpectationCalculationMethodB; use App\Filament\Widgets\Boxes\Helper\ExpectationCollecting; +use App\Filament\Widgets\Boxes\Helper\ExpectationsMinMax; use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryAll; use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryTP; use App\Utilities\Round; @@ -19,6 +20,7 @@ class ExpectationsTeam * STATTISTIC DATA */ $team_id = (int) $filter['team_id'] ?? 0; + $league_id = (int) $filter['league_id'] ?? 0; $team_position = $filter['team_position']; $similar_past_matches = $filter['similar_past_matches']; @@ -34,20 +36,13 @@ class ExpectationsTeam $res = LoadEventsQueryAll::load($filter, $match); - $res_tp = LoadEventsQueryTP::load($filter, $match); - - $count_tp = $res_tp->count(); - - // $count_events = ExpectationCounting::count($team_position, $team_id, $res); - - // Log::debug('count_events ' . $count_events); - if (! $res) { return []; } $tmp = []; foreach ($res as $value) { + // dd($match->home_id, $match->away_id, $value); ExpectationCollecting::sort($similar_past_matches, $tmp, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match); ExpectationCollecting::sort($similar_past_matches, $tmp, 'fls', $value->home_id, $value->away_id, $value->fls_h, $value->fls_a, $match); ExpectationCollecting::sort($similar_past_matches, $tmp, 'ofs', $value->home_id, $value->away_id, $value->ofs_h, $value->ofs_a, $match); @@ -63,6 +58,10 @@ class ExpectationsTeam $expectations = ExpectationCalculationMethodB::calc($tmp); } + // dd($expectations); + + ExpectationsMinMax::calc($expectations, $league_id); + $expectations['gls']['name'] = 'Goals'; $expectations['crn']['name'] = 'Corner'; $expectations['fls']['name'] = 'Fouls'; @@ -72,6 +71,10 @@ class ExpectationsTeam $expectations['tsh']['name'] = 'Total Shots'; $expectations['home'] = $home_team; $expectations['away'] = $away_team; + + $res_tp = LoadEventsQueryTP::load($filter, $match); + + $count_tp = $res_tp->count(); $expectations['count_events'] = $count_tp; $expectations += ['win_count' => 0, 'draw_count' => 0, 'lost_count' => 0]; diff --git a/app/Filament/Widgets/Boxes/Helper/ExpectationsMinMax.php b/app/Filament/Widgets/Boxes/Helper/ExpectationsMinMax.php new file mode 100644 index 00000000..56721f4a --- /dev/null +++ b/app/Filament/Widgets/Boxes/Helper/ExpectationsMinMax.php @@ -0,0 +1,79 @@ +get(); + $count = $res->count(); + + $data = []; + foreach ($bets as $bet) { + $data[$bet]['home'] = 0; + $data[$bet]['away'] = 0; + } + + foreach ($res as $val) { + + $data['crn']['home'] += $val->crn_h; + $data['crn']['away'] += $val->crn_a; + + $data['fls']['home'] += $val->fls_h; + $data['fls']['away'] += $val->fls_a; + + $data['ofs']['home'] += $val->ofs_h; + $data['ofs']['away'] += $val->ofs_a; + + $data['snt']['home'] += $val->snt_h; + $data['snt']['away'] += $val->snt_a; + + $data['tsh']['home'] += $val->tsh_h; + $data['tsh']['away'] += $val->tsh_a; + + $data['crd']['home'] += $val->crd_h; + $data['crd']['away'] += $val->crd_a; + } + + foreach ($data as $key => $value) { + $data[$key]['home'] = $value['home'] / $count; + $data[$key]['away'] = $value['away'] / $count; + } + + $final = []; + foreach ($data as $key => $value) { + if ($value['home'] > $value['away']) { + $final[$key]['max'] = round($value['home'] * (1 + $Y), 2); + $final[$key]['min'] = round($value['away'] * (1 - $Y), 2); + } else { + $final[$key]['min'] = round($value['home'] * (1 - $Y), 2); + $final[$key]['max'] = round($value['away'] * (1 + $Y), 2); + } + } + + foreach ($bets as $key) { + if ($expectations[$key]['home'] > $final[$key]['max']) { + $expectations[$key]['home'] = $final[$key]['max']; + } + if ($expectations[$key]['away'] > $final[$key]['max']) { + $expectations[$key]['away'] = $final[$key]['max']; + } + if ($expectations[$key]['home'] < $final[$key]['min']) { + $expectations[$key]['home'] = $final[$key]['min']; + } + if ($expectations[$key]['away'] < $final[$key]['min']) { + $expectations[$key]['away'] = $final[$key]['min']; + } + } + } +} diff --git a/app/Filament/Widgets/Charts/LoadEvents/LoadEventsQueryAll.php b/app/Filament/Widgets/Charts/LoadEvents/LoadEventsQueryAll.php index 8fd0501d..83089b17 100644 --- a/app/Filament/Widgets/Charts/LoadEvents/LoadEventsQueryAll.php +++ b/app/Filament/Widgets/Charts/LoadEvents/LoadEventsQueryAll.php @@ -11,7 +11,6 @@ class LoadEventsQueryAll public static function load(array $filter, object $match) { $league_id = (int) $filter['league_id'] ?? 0; - $team_id = (int) $filter['team_id'] ?? 0; $season = $filter['season']; $seasonmode = $filter['seasonmode']; $season_or_date = $filter['season_or_date'];