removed precalculation
This commit is contained in:
1 parent
f6f5dd0c7c
commit
838d6419f4
11 files changed
+214
-680
No files matched your search
@@ -9,12 +9,10 @@ use App\Filament\Widgets\PlayerProps\LineUpMap;
|
||||
use App\Filament\Widgets\PlayerProps\PositionHirarchie;
|
||||
use App\Livewire\PlayerCalculator;
|
||||
use App\Models\ExpectedMinimumPosition;
|
||||
use App\Models\SofaScorePlayerPerSeason;
|
||||
use App\Models\SofaScorePlayerPosition;
|
||||
use App\Models\SofaScoreRosa;
|
||||
use App\Models\SsLineupMemory;
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoDetail;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Widgets\Widget;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -392,24 +390,19 @@ class PlayerPropsDrop extends Widget
|
||||
$team_home_away = 'away';
|
||||
}
|
||||
|
||||
// $player_totals = LoadPlayerAverages::load($team_id, 'total');
|
||||
|
||||
$team_player_ids = StatistikoDetail::where('ss_team_id', $team_id)->pluck('ss_player_id')->toArray();
|
||||
$player_totals = SofaScorePlayerPerSeason::with('details')->where('season', 'total')->whereIn('ss_player_id', $team_player_ids)->get();
|
||||
$players = LoadPlayerAverages::load($team_id, 'total');
|
||||
|
||||
$count_player = 0;
|
||||
$tmp = [];
|
||||
foreach ($player_totals as $ss_player_id => $value) {
|
||||
$tmp[] = $ss_player_id;
|
||||
if ($value->details != null && $value->details->position != 'GK' && (int) $value->details->is_active) {
|
||||
foreach ($players as $ss_player_id => $value) {
|
||||
if ($value['position'] != 'GK') {
|
||||
$count_player++;
|
||||
}
|
||||
}
|
||||
|
||||
$results = [];
|
||||
|
||||
foreach ($player_totals as $val) {
|
||||
if ($val->details != null && $val->details->position != 'GK' && (int) $val->details->is_active) {
|
||||
foreach ($players as $val) {
|
||||
if ($val['position'] != 'GK') {
|
||||
|
||||
/***
|
||||
"goals" => 0
|
||||
@@ -421,12 +414,12 @@ class PlayerPropsDrop extends Widget
|
||||
"total_shots" => 4
|
||||
*/
|
||||
|
||||
$ss_player_id = $val->ss_player_id;
|
||||
$position = $val->details->position;
|
||||
$ss_player_id = $val['ss_player_id'];
|
||||
$position = $val['position'];
|
||||
|
||||
$tmp = [];
|
||||
$tmp['id'] = $ss_player_id;
|
||||
$tmp['name'] = $val->details->player_name;
|
||||
$tmp['name'] = $val['player_name'];
|
||||
|
||||
$tmp['id_team'] = $team_id;
|
||||
$tmp['asp_team'] = $asp_team;
|
||||
@@ -446,10 +439,10 @@ class PlayerPropsDrop extends Widget
|
||||
// Il valore Y dovrebbe essere configurabile in una interfaccia. Il valore iniziale lo fissiamo a Y = 180
|
||||
|
||||
// Somma Minuti Giocati da Player (SMG) nel DB
|
||||
$tmp['somma_minuti'] = $val->total_min;
|
||||
$tmp['shots_on_target'] = $val->shots_on_target;
|
||||
$tmp['shots_off_target'] = $val->shots_off_target;
|
||||
$tmp['shots_blocked'] = $val->shots_blocked;
|
||||
$tmp['somma_minuti'] = $val['total_min'];
|
||||
$tmp['shots_on_target'] = $val['shots_on_target'];
|
||||
$tmp['shots_off_target'] = $val['shots_off_target'];
|
||||
$tmp['shots_blocked'] = $val['shots_blocked'];
|
||||
|
||||
// il valore corrispondente al ruolo del Player (esempio un giocatore in Details ha ruolo = RW
|
||||
// quindi Aspettativa Statistica (AS) per RW = 0.219)
|
||||
@@ -479,8 +472,8 @@ class PlayerPropsDrop extends Widget
|
||||
|
||||
switch ($bettype) {
|
||||
case 'goals':
|
||||
$asp_gioco = $val->goals / $val->total_min * 90;
|
||||
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
||||
$asp_gioco = $val['goals'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
@@ -489,8 +482,8 @@ class PlayerPropsDrop extends Widget
|
||||
}
|
||||
break;
|
||||
case 'cards':
|
||||
$asp_gioco = $val->cards / $val->total_min * 90;
|
||||
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
||||
$asp_gioco = $val['cards'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
@@ -499,8 +492,8 @@ class PlayerPropsDrop extends Widget
|
||||
}
|
||||
break;
|
||||
case 'fouls':
|
||||
$asp_gioco = $val->fouls / $val->total_min * 90;
|
||||
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
||||
$asp_gioco = $val['fouls'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
@@ -509,8 +502,8 @@ class PlayerPropsDrop extends Widget
|
||||
}
|
||||
break;
|
||||
case 'offsides':
|
||||
$asp_gioco = $val->offsides / $val->total_min * 90;
|
||||
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
||||
$asp_gioco = $val['offsides'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
@@ -519,8 +512,8 @@ class PlayerPropsDrop extends Widget
|
||||
}
|
||||
break;
|
||||
case 'total_shots':
|
||||
$asp_gioco = $val->total_shots / $val->total_min * 90;
|
||||
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
||||
$asp_gioco = $val['total_shots'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
@@ -529,8 +522,8 @@ class PlayerPropsDrop extends Widget
|
||||
}
|
||||
break;
|
||||
case 'shots_on_target':
|
||||
$asp_gioco = $val->shots_on_target / $val->total_min * 90;
|
||||
if ($asp_gioco == 0 || $val->total_min < $this->y_value) {
|
||||
$asp_gioco = $val['shots_on_target'] / $val['total_min'] * 90;
|
||||
if ($asp_gioco == 0 || $val['total_min'] < $this->y_value) {
|
||||
$tmp['asp_gioco_'.$bettype] = 0;
|
||||
$tmp['asp_teorica_'.$bettype] = $asp_statistica;
|
||||
} else {
|
||||
@@ -629,41 +622,43 @@ class PlayerPropsDrop extends Widget
|
||||
$pos = $this->players[$k]['pos_ori'];
|
||||
}
|
||||
|
||||
$tamx = number_format($map[$pos]['gls'], 3);
|
||||
$final = number_format($result['asp_player_goals'], 3);
|
||||
$results[$key]['finale_tamx_gls'] = $tamx;
|
||||
$results[$key]['finale_calc_gls'] = $final;
|
||||
$this->players[$k]['gls'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
if ($pos != 'GK') {
|
||||
$tamx = number_format($map[$pos]['gls'], 3);
|
||||
$final = number_format($result['asp_player_goals'], 3);
|
||||
$results[$key]['finale_tamx_gls'] = $tamx;
|
||||
$results[$key]['finale_calc_gls'] = $final;
|
||||
$this->players[$k]['gls'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
|
||||
$tamx = number_format($map[$pos]['crd'], 3);
|
||||
$final = number_format($result['asp_player_cards'], 3);
|
||||
$results[$key]['finale_tamx_crd'] = $tamx;
|
||||
$results[$key]['finale_calc_crd'] = $final;
|
||||
$this->players[$k]['crd'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
$tamx = number_format($map[$pos]['crd'], 3);
|
||||
$final = number_format($result['asp_player_cards'], 3);
|
||||
$results[$key]['finale_tamx_crd'] = $tamx;
|
||||
$results[$key]['finale_calc_crd'] = $final;
|
||||
$this->players[$k]['crd'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
|
||||
$tamx = number_format($map[$pos]['fls'], 3);
|
||||
$final = number_format($result['asp_player_fouls'], 3);
|
||||
$results[$key]['finale_tamx_fls'] = $tamx;
|
||||
$results[$key]['finale_calc_fls'] = $final;
|
||||
$this->players[$k]['fls'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
$tamx = number_format($map[$pos]['fls'], 3);
|
||||
$final = number_format($result['asp_player_fouls'], 3);
|
||||
$results[$key]['finale_tamx_fls'] = $tamx;
|
||||
$results[$key]['finale_calc_fls'] = $final;
|
||||
$this->players[$k]['fls'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
|
||||
$tamx = number_format($map[$pos]['ofs'], 3);
|
||||
$final = number_format($result['asp_player_offsides'], 3);
|
||||
$results[$key]['finale_tamx_ofs'] = $tamx;
|
||||
$results[$key]['finale_calc_ofs'] = $final;
|
||||
$this->players[$k]['ofs'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
$tamx = number_format($map[$pos]['ofs'], 3);
|
||||
$final = number_format($result['asp_player_offsides'], 3);
|
||||
$results[$key]['finale_tamx_ofs'] = $tamx;
|
||||
$results[$key]['finale_calc_ofs'] = $final;
|
||||
$this->players[$k]['ofs'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
|
||||
$tamx = number_format($map[$pos]['tsh'], 3);
|
||||
$final = number_format($result['asp_player_total_shots'], 3);
|
||||
$results[$key]['finale_tamx_tsh'] = $tamx;
|
||||
$results[$key]['finale_calc_tsh'] = $final;
|
||||
$this->players[$k]['tsh'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
$tamx = number_format($map[$pos]['tsh'], 3);
|
||||
$final = number_format($result['asp_player_total_shots'], 3);
|
||||
$results[$key]['finale_tamx_tsh'] = $tamx;
|
||||
$results[$key]['finale_calc_tsh'] = $final;
|
||||
$this->players[$k]['tsh'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
|
||||
$tamx = number_format($map[$pos]['snt'], 3);
|
||||
$final = number_format($result['asp_player_shots_on_target'], 3);
|
||||
$results[$key]['finale_tamx_snt'] = $tamx;
|
||||
$results[$key]['finale_calc_snt'] = $final;
|
||||
$this->players[$k]['snt'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
$tamx = number_format($map[$pos]['snt'], 3);
|
||||
$final = number_format($result['asp_player_shots_on_target'], 3);
|
||||
$results[$key]['finale_tamx_snt'] = $tamx;
|
||||
$results[$key]['finale_calc_snt'] = $final;
|
||||
$this->players[$k]['snt'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -687,18 +682,16 @@ class PlayerPropsDrop extends Widget
|
||||
|
||||
public function prepareLineUp()
|
||||
{
|
||||
$team_player_ids = StatistikoDetail::where('ss_team_id', $this->team_id)->pluck('ss_player_id')->toArray();
|
||||
|
||||
$players = SofaScorePlayerPerSeason::with('details')->where('season', 'last_180_days')->whereIn('ss_player_id', $team_player_ids)->get();
|
||||
$players = LoadPlayerAverages::load($this->team_id, 'last180days');
|
||||
|
||||
$arr = collect();
|
||||
foreach ($players as $value) {
|
||||
if ($value?->details->position ?? 0) {
|
||||
if ($value['position'] != '') {
|
||||
$arr->push([
|
||||
'id' => $value->ss_player_id,
|
||||
'min' => $value->average_min,
|
||||
'pos' => $value->details->position,
|
||||
'name' => $value->details->player_name,
|
||||
'id' => $value['ss_player_id'],
|
||||
'min' => $value['average_min'],
|
||||
'pos' => $value['position'],
|
||||
'name' => $value['player_name'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user