This commit is contained in:
salam committed 2026-09-15 12:31:02 +02:00
1 parent 0cb9b16bad
commit e19b5ab54b
5 files changed
+50 -40

No files matched your search

+38 -33
View File
@@ -262,9 +262,9 @@ class PlayerPropsDrop extends Widget
foreach ($this->calculationVariables as $row) { foreach ($this->calculationVariables as $row) {
if ($copystring == '') { if ($copystring == '') {
$keys = array_keys($row); $keys = array_keys($row);
$copystring .= implode(';', $keys)."\n"; $copystring .= implode(';', $keys) . "\n";
} }
$copystring .= implode(';', $row)."\n"; $copystring .= implode(';', $row) . "\n";
} }
$this->js("navigator.clipboard.writeText(`$copystring`)"); $this->js("navigator.clipboard.writeText(`$copystring`)");
@@ -284,7 +284,7 @@ class PlayerPropsDrop extends Widget
return; return;
} }
$header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'snt', 'tsh', 'crd']; $header = ['name', 'foot', 'events', 'average min', 'position', 'on field', 'gls', 'fls', 'ofs', 'snt', 'tsh', 'crd'];
$copystring = implode(';', $header)."\n"; $copystring = implode(';', $header) . "\n";
foreach ($this->players as $row) { foreach ($this->players as $row) {
$tmp = []; $tmp = [];
$tmp[] = $row['name']; $tmp[] = $row['name'];
@@ -304,7 +304,7 @@ class PlayerPropsDrop extends Widget
$tmp[] = $row['tsh']; $tmp[] = $row['tsh'];
$tmp[] = $row['crd']; $tmp[] = $row['crd'];
$copystring .= implode(';', $tmp)."\n"; $copystring .= implode(';', $tmp) . "\n";
} }
$this->js("navigator.clipboard.writeText(`$copystring`)"); $this->js("navigator.clipboard.writeText(`$copystring`)");
@@ -416,6 +416,11 @@ class PlayerPropsDrop extends Widget
// Somma Minuti Giocati da Player (SMG) nel DB // Somma Minuti Giocati da Player (SMG) nel DB
$tmp['somma_minuti'] = $val->total_min; $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 // il valore corrispondente al ruolo del Player (esempio un giocatore in Details ha ruolo = RW
// quindi Aspettativa Statistica (AS) per RW = 0.219) // quindi Aspettativa Statistica (AS) per RW = 0.219)
// exp_goals // exp_goals
@@ -430,68 +435,68 @@ class PlayerPropsDrop extends Widget
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target']; $bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target'];
foreach ($bettypes as $bettype) { foreach ($bettypes as $bettype) {
$asp_statistica = (float) SofaScorePlayerPosition::where('ss_code', $position)->value('exp_'.$bettype); $asp_statistica = (float) SofaScorePlayerPosition::where('ss_code', $position)->value('exp_' . $bettype);
$tmp['asp_statistica_'.$bettype] = $asp_statistica; $tmp['asp_statistica_' . $bettype] = $asp_statistica;
switch ($bettype) { switch ($bettype) {
case 'goals': case 'goals':
if ($val->total_min < $this->y_value || $val->goals == 0) { if ($val->total_min < $this->y_value || $val->goals == 0) {
$tmp['asp_gioco_'.$bettype] = $asp_statistica; $tmp['asp_gioco_' . $bettype] = $asp_statistica;
$tmp['asp_teorica_'.$bettype] = $asp_statistica; $tmp['asp_teorica_' . $bettype] = $asp_statistica;
} else { } else {
$asp_gioco = $val->goals / $val->total_min * 90; $asp_gioco = $val->goals / $val->total_min * 90;
$tmp['asp_gioco_'.$bettype] = $asp_gioco; $tmp['asp_gioco_' . $bettype] = $asp_gioco;
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
} }
break; break;
case 'cards': case 'cards':
if ($val->total_min < $this->y_value || $val->cards == 0) { if ($val->total_min < $this->y_value || $val->cards == 0) {
$tmp['asp_gioco_'.$bettype] = $asp_statistica; $tmp['asp_gioco_' . $bettype] = $asp_statistica;
$tmp['asp_teorica_'.$bettype] = $asp_statistica; $tmp['asp_teorica_' . $bettype] = $asp_statistica;
} else { } else {
$asp_gioco = $val->cards / $val->total_min * 90; $asp_gioco = $val->cards / $val->total_min * 90;
$tmp['asp_gioco_'.$bettype] = $asp_gioco; $tmp['asp_gioco_' . $bettype] = $asp_gioco;
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
} }
break; break;
case 'fouls': case 'fouls':
if ($val->total_min < $this->y_value || $val->fouls == 0) { if ($val->total_min < $this->y_value || $val->fouls == 0) {
$tmp['asp_gioco_'.$bettype] = $asp_statistica; $tmp['asp_gioco_' . $bettype] = $asp_statistica;
$tmp['asp_teorica_'.$bettype] = $asp_statistica; $tmp['asp_teorica_' . $bettype] = $asp_statistica;
} else { } else {
$asp_gioco = $val->fouls / $val->total_min * 90; $asp_gioco = $val->fouls / $val->total_min * 90;
$tmp['asp_gioco_'.$bettype] = $asp_gioco; $tmp['asp_gioco_' . $bettype] = $asp_gioco;
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
} }
break; break;
case 'offsides': case 'offsides':
if ($val->total_min < $this->y_value || $val->offsides == 0) { if ($val->total_min < $this->y_value || $val->offsides == 0) {
$tmp['asp_gioco_'.$bettype] = $asp_statistica; $tmp['asp_gioco_' . $bettype] = $asp_statistica;
$tmp['asp_teorica_'.$bettype] = $asp_statistica; $tmp['asp_teorica_' . $bettype] = $asp_statistica;
} else { } else {
$asp_gioco = $val->offsides / $val->total_min * 90; $asp_gioco = $val->offsides / $val->total_min * 90;
$tmp['asp_gioco_'.$bettype] = $asp_gioco; $tmp['asp_gioco_' . $bettype] = $asp_gioco;
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
} }
break; break;
case 'total_shots': case 'total_shots':
if ($val->total_min < $this->y_value || $val->total_shots == 0) { if ($val->total_min < $this->y_value || $val->total_shots == 0) {
$tmp['asp_gioco_'.$bettype] = $asp_statistica; $tmp['asp_gioco_' . $bettype] = $asp_statistica;
$tmp['asp_teorica_'.$bettype] = $asp_statistica; $tmp['asp_teorica_' . $bettype] = $asp_statistica;
} else { } else {
$asp_gioco = $val->total_shots / $val->total_min * 90; $asp_gioco = $val->total_shots / $val->total_min * 90;
$tmp['asp_gioco_'.$bettype] = $asp_gioco; $tmp['asp_gioco_' . $bettype] = $asp_gioco;
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
} }
break; break;
case 'shots_on_target': case 'shots_on_target':
if ($val->total_min < $this->y_value || $val->shots_on_target == 0) { if ($val->total_min < $this->y_value || $val->shots_on_target == 0) {
$tmp['asp_gioco_'.$bettype] = $asp_statistica; $tmp['asp_gioco_' . $bettype] = $asp_statistica;
$tmp['asp_teorica_'.$bettype] = $asp_statistica; $tmp['asp_teorica_' . $bettype] = $asp_statistica;
} else { } else {
$asp_gioco = $val->shots_on_target / $val->total_min * 90; $asp_gioco = $val->shots_on_target / $val->total_min * 90;
$tmp['asp_gioco_'.$bettype] = $asp_gioco; $tmp['asp_gioco_' . $bettype] = $asp_gioco;
$tmp['asp_teorica_'.$bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value); $tmp['asp_teorica_' . $bettype] = ($this->x_value * $asp_gioco + $asp_statistica) / (1 + $this->x_value);
} }
break; break;
} }
@@ -508,14 +513,14 @@ class PlayerPropsDrop extends Widget
$bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target']; $bettypes = ['goals', 'cards', 'fouls', 'offsides', 'total_shots', 'shots_on_target'];
foreach ($bettypes as $bettype) { foreach ($bettypes as $bettype) {
$total_bettype = array_sum(array_column($results, 'asp_teorica_'.$bettype)); $total_bettype = array_sum(array_column($results, 'asp_teorica_' . $bettype));
foreach ($results as $key => $value) { foreach ($results as $key => $value) {
// Aspettativa per Player: AP = AT * ATR / TOT AT // Aspettativa per Player: AP = AT * ATR / TOT AT
$results[$key]['asp_total_'.$bettype] = $total_bettype; $results[$key]['asp_total_' . $bettype] = $total_bettype;
// $results[$key]['asp_player_'.$bettype] = ((float) $value['asp_team'] * (float) $value['asp_teorica_'.$bettype]) / $total_bettype; // $results[$key]['asp_player_'.$bettype] = ((float) $value['asp_team'] * (float) $value['asp_teorica_'.$bettype]) / $total_bettype;
// $results[$key]['asp_player_'.$bettype] = ($asp_team * $asp_team_riferimento) / $total_bettype; // $results[$key]['asp_player_'.$bettype] = ($asp_team * $asp_team_riferimento) / $total_bettype;
$results[$key]['asp_player_'.$bettype] = ($value['asp_teorica_'.$bettype] * $asp_team_riferimento) / $total_bettype; $results[$key]['asp_player_' . $bettype] = ($value['asp_teorica_' . $bettype] * $asp_team_riferimento) / $total_bettype;
} }
} }
+3 -4
View File
@@ -86,10 +86,9 @@ class PlayerCalculator extends Component
// dd($result); // dd($result);
$pos = array_column($result, 'pos'); // $pos = array_column($result, 'pos');
$area = array_column($result, 'area'); // $area = array_column($result, 'area');
// array_multisort($area, SORT_ASC, $pos, SORT_ASC, $result);
array_multisort($area, SORT_ASC, $pos, SORT_ASC, $result);
return $result; return $result;
} }
+1
View File
@@ -25,6 +25,7 @@ class SofaScorePlayerPerSeason extends Model
'offsides', 'offsides',
'shots_on_target', 'shots_on_target',
'shots_off_target', 'shots_off_target',
'shots_blocked',
'total_shots', 'total_shots',
]; ];
+7 -3
View File
@@ -48,7 +48,7 @@ trait UpdateHelper
try { try {
$this->updatePlayers($playerCount); $this->updatePlayers($playerCount);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->error(get_class($e).' '.Str::of($e->getMessage())->limit(100)->value()); $this->error(get_class($e) . ' ' . Str::of($e->getMessage())->limit(100)->value());
} }
if ($this->debug) { if ($this->debug) {
@@ -97,8 +97,8 @@ trait UpdateHelper
$formattedTime = match (true) { $formattedTime = match (true) {
$executionTime >= 60 => sprintf('%dm %ds', floor($executionTime / 60), $executionTime % 60), $executionTime >= 60 => sprintf('%dm %ds', floor($executionTime / 60), $executionTime % 60),
$executionTime >= 1 => round($executionTime, 2).'s', $executionTime >= 1 => round($executionTime, 2) . 's',
default => round($executionTime * 1000).'ms', default => round($executionTime * 1000) . 'ms',
}; };
$this->newLine(); $this->newLine();
@@ -169,6 +169,7 @@ trait UpdateHelper
$collection[$season][$ss_player_id]['offsides'] += $val->offsides; $collection[$season][$ss_player_id]['offsides'] += $val->offsides;
$collection[$season][$ss_player_id]['shots_on_target'] += $val->shots_on_target; $collection[$season][$ss_player_id]['shots_on_target'] += $val->shots_on_target;
$collection[$season][$ss_player_id]['shots_off_target'] += $val->shots_off_target; $collection[$season][$ss_player_id]['shots_off_target'] += $val->shots_off_target;
$collection[$season][$ss_player_id]['shots_blocked'] += $val->shots_blocked;
$collection[$season][$ss_player_id]['total_shots'] += $val->shots_off_target + $val->shots_off_target + $val->shots_blocked; $collection[$season][$ss_player_id]['total_shots'] += $val->shots_off_target + $val->shots_off_target + $val->shots_blocked;
$collection['total'][$ss_player_id]['ss_player_id'] = $ss_player_id; $collection['total'][$ss_player_id]['ss_player_id'] = $ss_player_id;
@@ -183,6 +184,7 @@ trait UpdateHelper
$collection['total'][$ss_player_id]['offsides'] += $val->offsides; $collection['total'][$ss_player_id]['offsides'] += $val->offsides;
$collection['total'][$ss_player_id]['shots_on_target'] += $val->shots_on_target; $collection['total'][$ss_player_id]['shots_on_target'] += $val->shots_on_target;
$collection['total'][$ss_player_id]['shots_off_target'] += $val->shots_off_target; $collection['total'][$ss_player_id]['shots_off_target'] += $val->shots_off_target;
$collection['total'][$ss_player_id]['shots_blocked'] += $val->shots_blocked;
$collection['total'][$ss_player_id]['total_shots'] += $val->shots_off_target + $val->shots_off_target + $val->shots_blocked; $collection['total'][$ss_player_id]['total_shots'] += $val->shots_off_target + $val->shots_off_target + $val->shots_blocked;
} }
} }
@@ -215,6 +217,7 @@ trait UpdateHelper
'offsides', 'offsides',
'shots_on_target', 'shots_on_target',
'shots_off_target', 'shots_off_target',
'shots_blocked',
'total_shots', 'total_shots',
'cards', 'cards',
] ]
@@ -239,6 +242,7 @@ trait UpdateHelper
$collection[$season][$ss_player_id]['offsides'] = 0; $collection[$season][$ss_player_id]['offsides'] = 0;
$collection[$season][$ss_player_id]['shots_on_target'] = 0; $collection[$season][$ss_player_id]['shots_on_target'] = 0;
$collection[$season][$ss_player_id]['shots_off_target'] = 0; $collection[$season][$ss_player_id]['shots_off_target'] = 0;
$collection[$season][$ss_player_id]['shots_blocked'] = 0;
$collection[$season][$ss_player_id]['total_shots'] = 0; $collection[$season][$ss_player_id]['total_shots'] = 0;
$collection[$season][$ss_player_id]['cards'] = 0; $collection[$season][$ss_player_id]['cards'] = 0;
} }
@@ -29,6 +29,7 @@ return new class extends Migration
$table->integer('offsides')->default(0)->nullable(); $table->integer('offsides')->default(0)->nullable();
$table->integer('shots_on_target')->default(0)->nullable(); $table->integer('shots_on_target')->default(0)->nullable();
$table->integer('shots_off_target')->default(0)->nullable(); $table->integer('shots_off_target')->default(0)->nullable();
$table->integer('shots_blocked')->default(0)->nullable();
$table->integer('total_shots')->default(0)->nullable(); $table->integer('total_shots')->default(0)->nullable();
$table->unique(['ss_player_id', 'ss_team_id', 'season']); $table->unique(['ss_player_id', 'ss_team_id', 'season']);
$table->timestamps(); $table->timestamps();