This commit is contained in:
salam committed 2026-10-09 13:02:44 +02:00
1 parent 8cb1d428cb
commit 0a936bc84b
6 files changed
+190 -100

No files matched your search

@@ -2,7 +2,8 @@
namespace App\Filament\Widgets\Boxes;
use App\Filament\Widgets\Boxes\Helper\ExpectationCalculation;
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\Charts\LoadEvents\LoadEventsQueryAll;
use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryTP;
@@ -10,6 +11,8 @@ use App\Utilities\Round;
class ExpectationsTeam
{
public static $collectionMethod = 'B';
public static function load(array &$expectations, array $filter, object $match)
{
/**
@@ -30,7 +33,6 @@ class ExpectationsTeam
}
$res = LoadEventsQueryAll::load($filter, $match);
// dd($res);
$res_tp = LoadEventsQueryTP::load($filter, $match);
@@ -55,8 +57,12 @@ class ExpectationsTeam
ExpectationCollecting::sort($similar_past_matches, $tmp, 'crn', $value->home_id, $value->away_id, $value->crn_h, $value->crn_a, $match);
}
if (self::$collectionMethod == 'A') {
$expectations = ExpectationCalculationMethodA::calc($tmp);
} else {
$expectations = ExpectationCalculationMethodB::calc($tmp);
}
$expectations = ExpectationCalculation::calc($tmp);
$expectations['gls']['name'] = 'Goals';
$expectations['fls']['name'] = 'Fouls';
$expectations['ofs']['name'] = 'Offsides';
@@ -4,7 +4,7 @@ namespace App\Filament\Widgets\Boxes\Helper;
use App\Models\StatistikoConfig;
class ExpectationCalculation
class ExpectationCalculationMethodA
{
public static function calc(array $expectations)
{
@@ -0,0 +1,42 @@
<?php
namespace App\Filament\Widgets\Boxes\Helper;
class ExpectationCalculationMethodB
{
public static function calc(array $expectations)
{
// ok in pratica made = scored e got = conceded
$cfHA = 2;
$result = [];
foreach ($expectations as $bettype => $data) {
$result[$bettype]['home'] = round((
$data['team_home']['scored']['home']['sum'] * $cfHA +
$data['team_home']['scored']['away']['sum'] +
$data['team_away']['conceded']['away']['sum'] * $cfHA +
$data['team_away']['conceded']['home']['sum']
) / (
$data['team_home']['scored']['home']['evt'] * $cfHA +
$data['team_home']['scored']['away']['evt'] +
$data['team_away']['conceded']['home']['evt'] +
$data['team_away']['conceded']['away']['evt'] * $cfHA
), 1);
$result[$bettype]['away'] = round((
$data['team_home']['conceded']['home']['sum'] * $cfHA +
$data['team_home']['conceded']['away']['sum'] +
$data['team_away']['scored']['away']['sum'] * $cfHA +
$data['team_away']['scored']['home']['sum']
) / (
$data['team_home']['conceded']['home']['evt'] * $cfHA +
$data['team_home']['conceded']['away']['evt'] +
$data['team_away']['scored']['home']['evt'] +
$data['team_away']['scored']['away']['evt'] * $cfHA
), 1);
}
return $result;
}
}
@@ -2,48 +2,89 @@
namespace App\Filament\Widgets\Boxes\Helper;
use App\Filament\Widgets\Boxes\ExpectationsTeam;
class ExpectationCollecting
{
public static function sort(string $similar_past_matches, array &$result, string $type, int $home_id, int $away_id, float $val_home, float $val_away, object $match)
public static function add(array &$result, string $team, string $bettype, string $scored_conceded, string $location, int $value)
{
if (! isset($result[$bettype][$team][$scored_conceded][$location])) {
$result[$bettype][$team][$scored_conceded][$location]['evt'] = 1;
$result[$bettype][$team][$scored_conceded][$location]['sum'] = $value;
} else {
$result[$bettype][$team][$scored_conceded][$location]['evt']++;
$result[$bettype][$team][$scored_conceded][$location]['sum'] += $value;
}
}
// ExpectationCollecting::sort($similar_past_matches, $tmp, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match);
public static function sort(string $similar_past_matches, array &$result, string $bettype, int $home_id, int $away_id, float $val_home, float $val_away, object $match)
{
/**
* takes values form statistiko_conf table
* there are 2 mthods A and B noe running B hardcodet
*/
if ($similar_past_matches != 'none') {
$result[$type.'_home_made_total'][] = $val_home;
$result[$type.'_away_made_total'][] = $val_away;
$result[$bettype.'_home_made_total'][] = $val_home;
$result[$bettype.'_away_made_total'][] = $val_away;
} elseif (ExpectationsTeam::$collectionMethod == 'B') {
// TEAM HOME
if ($match->home_id == $home_id) {
self::add($result, 'team_home', $bettype, 'scored', 'home', $val_home);
self::add($result, 'team_home', $bettype, 'conceded', 'home', $val_away);
}
if ($match->home_id == $away_id) {
self::add($result, 'team_home', $bettype, 'scored', 'away', $val_away);
self::add($result, 'team_home', $bettype, 'conceded', 'away', $val_home);
}
// TEAM AWAY
if ($match->away_id == $home_id) {
self::add($result, 'team_away', $bettype, 'scored', 'home', $val_home);
self::add($result, 'team_away', $bettype, 'conceded', 'home', $val_away);
}
if ($match->away_id == $away_id) {
self::add($result, 'team_away', $bettype, 'scored', 'away', $val_away);
self::add($result, 'team_away', $bettype, 'conceded', 'away', $val_home);
}
} else {
if ($home_id == $match->home_id) {
$result[$type.'_home_made_total'][] = $val_home;
$result[$type.'_home_made_home'][] = $val_home;
$result[$type.'_home_got_total'][] = $val_away;
$result[$type.'_home_got_home'][] = $val_away;
$result[$bettype.'_home_made_total'][] = $val_home;
$result[$bettype.'_home_made_home'][] = $val_home;
$result[$bettype.'_home_got_total'][] = $val_away;
$result[$bettype.'_home_got_home'][] = $val_away;
} elseif ($away_id == $match->home_id) {
$result[$type.'_home_made_total'][] = $val_away;
$result[$type.'_home_got_total'][] = $val_away;
$result[$bettype.'_home_made_total'][] = $val_away;
$result[$bettype.'_home_got_total'][] = $val_away;
} elseif ($home_id == $match->away_id) {
$result[$type.'_home_made_total'][] = $val_away;
$result[$type.'_home_got_total'][] = $val_away;
$result[$bettype.'_home_made_total'][] = $val_away;
$result[$bettype.'_home_got_total'][] = $val_away;
} elseif ($away_id == $match->away_id) {
$result[$type.'_home_made_total'][] = $val_home;
$result[$type.'_home_made_home'][] = $val_home;
$result[$type.'_home_got_total'][] = $val_away;
$result[$type.'_home_got_home'][] = $val_home;
$result[$bettype.'_home_made_total'][] = $val_home;
$result[$bettype.'_home_made_home'][] = $val_home;
$result[$bettype.'_home_got_total'][] = $val_away;
$result[$bettype.'_home_got_home'][] = $val_home;
}
if ($away_id == $match->away_id) {
$result[$type.'_away_made_total'][] = $val_away;
$result[$type.'_away_made_home'][] = $val_away;
$result[$type.'_away_got_total'][] = $val_home;
$result[$type.'_away_got_home'][] = $val_home;
$result[$bettype.'_away_made_total'][] = $val_away;
$result[$bettype.'_away_made_home'][] = $val_away;
$result[$bettype.'_away_got_total'][] = $val_home;
$result[$bettype.'_away_got_home'][] = $val_home;
} elseif ($home_id == $match->away_id) {
$result[$type.'_away_made_total'][] = $val_home;
$result[$type.'_away_got_total'][] = $val_home;
$result[$bettype.'_away_made_total'][] = $val_home;
$result[$bettype.'_away_got_total'][] = $val_home;
} elseif ($away_id == $match->home_id) {
$result[$type.'_away_made_total'][] = $val_home;
$result[$type.'_away_got_total'][] = $val_home;
$result[$bettype.'_away_made_total'][] = $val_home;
$result[$bettype.'_away_got_total'][] = $val_home;
} elseif ($home_id == $match->home_id) {
$result[$type.'_away_made_total'][] = $val_away;
$result[$type.'_away_made_home'][] = $val_away;
$result[$type.'_away_got_total'][] = $val_home;
$result[$type.'_away_got_home'][] = $val_away;
$result[$bettype.'_away_made_total'][] = $val_away;
$result[$bettype.'_away_made_home'][] = $val_away;
$result[$bettype.'_away_got_total'][] = $val_home;
$result[$bettype.'_away_got_home'][] = $val_away;
}
}
}
@@ -47,9 +47,11 @@ class LoadEventsQueryAll
if ($ss_player_id) {
$matches_season = StatistikoEvent::whereIn('season', $season)
->where(function ($query) use ($team_id) {
return $query->where('home_id', '=', $team_id)
->orWhere('away_id', '=', $team_id);
->where(function ($query) use ($match) {
return $query->where('home_id', '=', $match->home_id)
->orWhere('home_id', '=', $match->away_id)
->orWhere('away_id', '=', $match->home_id)
->orWhere('away_id', '=', $match->away_id);
})->pluck('match_id')->toArray();
$matches_played = StatistikoPlayer::query()
@@ -92,16 +94,14 @@ class LoadEventsQueryAll
return $query->where('league_id', $league_id);
}
})
->where(function ($query) use ($team_id, $similar_past_matches) {
if ($team_id && $similar_past_matches == 'none') {
return $query->where('home_id', '=', $team_id)
->orWhere('away_id', '=', $team_id);
->where(function ($query) use ($match, $similar_past_matches) {
if ($similar_past_matches == 'none') {
return $query->where('home_id', '=', $match->home_id)
->orWhere('home_id', '=', $match->away_id)
->orWhere('away_id', '=', $match->home_id)
->orWhere('away_id', '=', $match->away_id);
}
})
// ->when($team_id, function ($query) use ($team_id) {
// return $query->where('home_id', '=', $team_id)
// ->orWhere('away_id', '=', $team_id);
// })
->when($matches_played, function ($query) use ($matches_played, $player_on_field) {
if ($player_on_field == 'notplayed') {
return $query->whereNotIn('match_id', $matches_played);
+59 -58
View File
@@ -9,65 +9,66 @@ class StatistikoConfigSeeder extends Seeder
{
public function run(): void
{
$sql = "INSERT INTO `statistiko_configs` (`id`, `group`, `team`, `varname`, `value`, `created_at`, `updated_at`)
$sql = "INSERT INTO `statistiko_configs` (`id`, `type`, `group`, `team`, `varname`, `value`, `created_at`, `updated_at`)
VALUES
(1, 'gls', 'home', 'gls_home_made_total', '1', NULL, NULL),
(2, 'gls', 'home', 'gls_home_made_home', '1', NULL, NULL),
(3, 'gls', 'home', 'gls_home_got_total', '1', NULL, NULL),
(4, 'gls', 'home', 'gls_home_got_home', '1', NULL, NULL),
(5, 'gls', 'away', 'gls_away_made_total', '1', NULL, NULL),
(6, 'gls', 'away', 'gls_away_made_home', '1', NULL, NULL),
(7, 'gls', 'away', 'gls_away_got_total', '1', NULL, NULL),
(8, 'gls', 'away', 'gls_away_got_home', '1', NULL, NULL),
(9, 'crn', 'home', 'crn_home_made_total', '1', NULL, NULL),
(10, 'crn', 'home', 'crn_home_made_home', '1', NULL, NULL),
(11, 'crn', 'home', 'crn_home_got_total', '1', NULL, NULL),
(12, 'crn', 'home', 'crn_home_got_home', '1', NULL, NULL),
(13, 'crn', 'away', 'crn_away_made_total', '1', NULL, NULL),
(14, 'crn', 'away', 'crn_away_made_home', '1', NULL, NULL),
(15, 'crn', 'away', 'crn_away_got_total', '1', NULL, NULL),
(16, 'crn', 'away', 'crn_away_got_home', '1', NULL, NULL),
(17, 'fls', 'home', 'fls_home_made_total', '1', NULL, NULL),
(18, 'fls', 'home', 'fls_home_made_home', '1', NULL, NULL),
(19, 'fls', 'home', 'fls_home_got_total', '1', NULL, NULL),
(20, 'fls', 'home', 'fls_home_got_home', '1', NULL, NULL),
(21, 'fls', 'away', 'fls_away_made_total', '1', NULL, NULL),
(22, 'fls', 'away', 'fls_away_made_home', '1', NULL, NULL),
(23, 'fls', 'away', 'fls_away_got_total', '1', NULL, NULL),
(24, 'fls', 'away', 'fls_away_got_home', '1', NULL, NULL),
(25, 'ofs', 'home', 'ofs_home_made_total', '1', NULL, NULL),
(26, 'ofs', 'home', 'ofs_home_made_home', '1', NULL, NULL),
(27, 'ofs', 'home', 'ofs_home_got_total', '1', NULL, NULL),
(28, 'ofs', 'home', 'ofs_home_got_home', '1', NULL, NULL),
(29, 'ofs', 'away', 'ofs_away_made_total', '1', NULL, NULL),
(30, 'ofs', 'away', 'ofs_away_made_home', '1', NULL, NULL),
(31, 'ofs', 'away', 'ofs_away_got_total', '1', NULL, NULL),
(32, 'ofs', 'away', 'ofs_away_got_home', '1', NULL, NULL),
(33, 'crd', 'home', 'crd_home_made_total', '1', NULL, NULL),
(34, 'crd', 'home', 'crd_home_made_home', '1', NULL, NULL),
(35, 'crd', 'home', 'crd_home_got_total', '1', NULL, NULL),
(36, 'crd', 'home', 'crd_home_got_home', '1', NULL, NULL),
(37, 'crd', 'away', 'crd_away_made_total', '1', NULL, NULL),
(38, 'crd', 'away', 'crd_away_made_home', '1', NULL, NULL),
(39, 'crd', 'away', 'crd_away_got_total', '1', NULL, NULL),
(40, 'crd', 'away', 'crd_away_got_home', '1', NULL, NULL),
(41, 'snt', 'home', 'snt_home_made_total', '1', NULL, NULL),
(42, 'snt', 'home', 'snt_home_made_home', '1', NULL, NULL),
(43, 'snt', 'home', 'snt_home_got_total', '1', NULL, NULL),
(44, 'snt', 'home', 'snt_home_got_home', '1', NULL, NULL),
(45, 'snt', 'away', 'snt_away_made_total', '1', NULL, NULL),
(46, 'snt', 'away', 'snt_away_made_home', '1', NULL, NULL),
(47, 'snt', 'away', 'snt_away_got_total', '1', NULL, NULL),
(48, 'snt', 'away', 'snt_away_got_home', '1', NULL, NULL),
(49, 'tsh', 'home', 'tsh_home_made_total', '1', NULL, NULL),
(50, 'tsh', 'home', 'tsh_home_made_home', '1', NULL, NULL),
(51, 'tsh', 'home', 'tsh_home_got_total', '1', NULL, NULL),
(52, 'tsh', 'home', 'tsh_home_got_home', '1', NULL, NULL),
(53, 'tsh', 'away', 'tsh_away_made_total', '1', NULL, NULL),
(54, 'tsh', 'away', 'tsh_away_made_home', '1', NULL, NULL),
(55, 'tsh', 'away', 'tsh_away_got_total', '1', NULL, NULL),
(56, 'tsh', 'away', 'tsh_away_got_home', '1', NULL, NULL);
";
(1, 'A', 'gls', 'home', 'gls_home_made_total', 1.00, NULL, '2026-08-14 17:37:29'),
(2, 'A', 'gls', 'home', 'gls_home_made_home', 1.00, NULL, NULL),
(3, 'A', 'gls', 'home', 'gls_home_got_total', 1.00, NULL, NULL),
(4, 'A', 'gls', 'home', 'gls_home_got_home', 1.00, NULL, NULL),
(5, 'A', 'gls', 'away', 'gls_away_made_total', 1.00, NULL, NULL),
(6, 'A', 'gls', 'away', 'gls_away_made_home', 1.00, NULL, NULL),
(7, 'A', 'gls', 'away', 'gls_away_got_total', 1.00, NULL, NULL),
(8, 'A', 'gls', 'away', 'gls_away_got_home', 1.00, NULL, NULL),
(9, 'A', 'crn', 'home', 'crn_home_made_total', 1.00, NULL, NULL),
(10, 'A', 'crn', 'home', 'crn_home_made_home', 1.00, NULL, NULL),
(11, 'A', 'crn', 'home', 'crn_home_got_total', 1.00, NULL, NULL),
(12, 'A', 'crn', 'home', 'crn_home_got_home', 1.00, NULL, NULL),
(13, 'A', 'crn', 'away', 'crn_away_made_total', 1.00, NULL, NULL),
(14, 'A', 'crn', 'away', 'crn_away_made_home', 1.00, NULL, NULL),
(15, 'A', 'crn', 'away', 'crn_away_got_total', 1.00, NULL, NULL),
(16, 'A', 'crn', 'away', 'crn_away_got_home', 1.00, NULL, NULL),
(17, 'A', 'fls', 'home', 'fls_home_made_total', 1.00, NULL, NULL),
(18, 'A', 'fls', 'home', 'fls_home_made_home', 1.00, NULL, NULL),
(19, 'A', 'fls', 'home', 'fls_home_got_total', 1.00, NULL, NULL),
(20, 'A', 'fls', 'home', 'fls_home_got_home', 1.00, NULL, NULL),
(21, 'A', 'fls', 'away', 'fls_away_made_total', 1.00, NULL, NULL),
(22, 'A', 'fls', 'away', 'fls_away_made_home', 1.00, NULL, NULL),
(23, 'A', 'fls', 'away', 'fls_away_got_total', 1.00, NULL, NULL),
(24, 'A', 'fls', 'away', 'fls_away_got_home', 1.00, NULL, NULL),
(25, 'A', 'ofs', 'home', 'ofs_home_made_total', 1.00, NULL, NULL),
(26, 'A', 'ofs', 'home', 'ofs_home_made_home', 1.00, NULL, NULL),
(27, 'A', 'ofs', 'home', 'ofs_home_got_total', 1.00, NULL, NULL),
(28, 'A', 'ofs', 'home', 'ofs_home_got_home', 1.00, NULL, NULL),
(29, 'A', 'ofs', 'away', 'ofs_away_made_total', 1.00, NULL, NULL),
(30, 'A', 'ofs', 'away', 'ofs_away_made_home', 1.00, NULL, NULL),
(31, 'A', 'ofs', 'away', 'ofs_away_got_total', 1.00, NULL, NULL),
(32, 'A', 'ofs', 'away', 'ofs_away_got_home', 1.00, NULL, NULL),
(33, 'A', 'crd', 'home', 'crd_home_made_total', 1.00, NULL, NULL),
(34, 'A', 'crd', 'home', 'crd_home_made_home', 1.00, NULL, NULL),
(35, 'A', 'crd', 'home', 'crd_home_got_total', 1.00, NULL, NULL),
(36, 'A', 'crd', 'home', 'crd_home_got_home', 1.00, NULL, NULL),
(37, 'A', 'crd', 'away', 'crd_away_made_total', 1.00, NULL, NULL),
(38, 'A', 'crd', 'away', 'crd_away_made_home', 1.00, NULL, NULL),
(39, 'A', 'crd', 'away', 'crd_away_got_total', 1.00, NULL, NULL),
(40, 'A', 'crd', 'away', 'crd_away_got_home', 1.00, NULL, NULL),
(41, 'A', 'snt', 'home', 'snt_home_made_total', 1.00, NULL, NULL),
(42, 'A', 'snt', 'home', 'snt_home_made_home', 1.00, NULL, NULL),
(43, 'A', 'snt', 'home', 'snt_home_got_total', 1.00, NULL, NULL),
(44, 'A', 'snt', 'home', 'snt_home_got_home', 1.00, NULL, NULL),
(45, 'A', 'snt', 'away', 'snt_away_made_total', 1.00, NULL, NULL),
(46, 'A', 'snt', 'away', 'snt_away_made_home', 1.00, NULL, NULL),
(47, 'A', 'snt', 'away', 'snt_away_got_total', 1.00, NULL, NULL),
(48, 'A', 'snt', 'away', 'snt_away_got_home', 1.00, NULL, NULL),
(49, 'A', 'tsh', 'home', 'tsh_home_made_total', 1.00, NULL, NULL),
(50, 'A', 'tsh', 'home', 'tsh_home_made_home', 1.00, NULL, NULL),
(51, 'A', 'tsh', 'home', 'tsh_home_got_total', 1.00, NULL, NULL),
(52, 'A', 'tsh', 'home', 'tsh_home_got_home', 1.00, NULL, NULL),
(53, 'A', 'tsh', 'away', 'tsh_away_made_total', 1.00, NULL, NULL),
(54, 'A', 'tsh', 'away', 'tsh_away_made_home', 1.00, NULL, NULL),
(55, 'A', 'tsh', 'away', 'tsh_away_got_total', 1.00, NULL, NULL),
(56, 'A', 'tsh', 'away', 'tsh_away_got_home', 1.00, NULL, NULL),
(57, 'B', 'all', 'home', 'asp_home', 2.00, NULL, NULL),
(58, 'B', 'all', 'away', 'asp_away', 2.00, NULL, NULL);";
DB::unprepared($sql);
}