wip
This commit is contained in:
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';
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user