fix import player, new columns remove telescope, consider emty vars in PlayerDataMerge
This commit is contained in:
1 parent
43013d3eec
commit
bef576616f
14 files changed
+553
-1437
No files matched your search
@@ -15,6 +15,9 @@ trait PlayerDataMerge
|
||||
$part2 = $filtered_part_2[$players_id] ?? [];
|
||||
|
||||
$this->players[$k]['active'] = $part1['active'] ?? 0;
|
||||
if (! $this->players[$k]['active'] && isset($part2['active']) && $part2['active'] == 1) {
|
||||
$this->players[$k]['active'] = 1;
|
||||
}
|
||||
|
||||
$bets = ['gls', 'crn', 'fls', 'ofs', 'crd', 'snt', 'tsh', 'wfl'];
|
||||
foreach ($bets as $bet) {
|
||||
@@ -28,6 +31,12 @@ trait PlayerDataMerge
|
||||
$val1 = $part1[$bettype] ?? 0;
|
||||
$val2 = $part2[$bettype] ?? 0;
|
||||
|
||||
return number_format(($val2 * (100 - $this->part_1_value) + $val1 * $this->part_1_value) / 100, 3);
|
||||
if ($val1 && $val1) {
|
||||
return number_format(($val2 * (100 - $this->part_1_value) + $val1 * $this->part_1_value) / 100, 3);
|
||||
} elseif ($val1) {
|
||||
return number_format($val1, 3);
|
||||
} elseif ($val2) {
|
||||
return number_format($val2, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -252,44 +252,44 @@ trait PlayerFilter
|
||||
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;
|
||||
// $results[$key]['finale_tamx_gls'] = $tamx;
|
||||
// $results[$key]['finale_calc_gls'] = $final;
|
||||
$return[$id]['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;
|
||||
// $results[$key]['finale_tamx_crd'] = $tamx;
|
||||
// $results[$key]['finale_calc_crd'] = $final;
|
||||
$return[$id]['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;
|
||||
// $results[$key]['finale_tamx_fls'] = $tamx;
|
||||
// $results[$key]['finale_calc_fls'] = $final;
|
||||
$return[$id]['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;
|
||||
// $results[$key]['finale_tamx_ofs'] = $tamx;
|
||||
// $results[$key]['finale_calc_ofs'] = $final;
|
||||
$return[$id]['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;
|
||||
// $results[$key]['finale_tamx_tsh'] = $tamx;
|
||||
// $results[$key]['finale_calc_tsh'] = $final;
|
||||
$return[$id]['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;
|
||||
// $results[$key]['finale_tamx_snt'] = $tamx;
|
||||
// $results[$key]['finale_calc_snt'] = $final;
|
||||
$return[$id]['snt'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
|
||||
$tamx = number_format($map[$pos]['wfl'], 3);
|
||||
$final = number_format($result['asp_player_was_fouled'], 3);
|
||||
$results[$key]['finale_tamx_wfl'] = $tamx;
|
||||
$results[$key]['finale_calc_wfl'] = $final;
|
||||
// $results[$key]['finale_tamx_wfl'] = $tamx;
|
||||
// $results[$key]['finale_calc_wfl'] = $final;
|
||||
$return[$id]['wfl'] = (float) $final > (float) $tamx ? $final : $tamx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,57 +4,28 @@ namespace App\Traits\PlayerProps;
|
||||
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
// use Illuminate\Support\Facades\Log;
|
||||
|
||||
trait PlayerQuery
|
||||
{
|
||||
public function loadPartsPlayer(int $part, object $players): array
|
||||
{
|
||||
if (! $this->team_id) {
|
||||
return [];
|
||||
}
|
||||
if (! $this->liga_id) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$player_ids = [];
|
||||
foreach ($players as $row) {
|
||||
$player_ids[] = $row->ss_player_id;
|
||||
}
|
||||
|
||||
$matches_ids = [];
|
||||
switch ($this->season_or_date) {
|
||||
case 'season':
|
||||
if (! $this->season_selected) {
|
||||
$this->season_selected = $this->getCurrentSeason();
|
||||
}
|
||||
|
||||
// Log::debug('home_id away_id', [$this->home_id, $this->away_id]);
|
||||
|
||||
$matches_ids = match ($part) {
|
||||
1 => StatistikoEvent::where('league_id', $this->liga_id)
|
||||
->when($this->season_selected, function ($query) {
|
||||
return $query->whereIn('season', $this->season_selected);
|
||||
})->pluck('match_id')->toArray(),
|
||||
2 => StatistikoEvent::where('league_id', $this->liga_id)
|
||||
->when($this->season_selected, function ($query) {
|
||||
return $query->whereNotIn('season', $this->season_selected);
|
||||
})->pluck('match_id')->toArray()
|
||||
};
|
||||
break;
|
||||
default:
|
||||
$matches_ids = match ($part) {
|
||||
1 => StatistikoEvent::where('league_id', $this->liga_id)
|
||||
->when($this->date_spliter, function ($query) {
|
||||
return $query->whereDate('starttime', '>', $this->date_spliter);
|
||||
})->pluck('match_id')->toArray(),
|
||||
2 => StatistikoEvent::where('league_id', $this->liga_id)
|
||||
->when($this->season_selected, function ($query) {
|
||||
return $query->whereDate('starttime', '<=', $this->date_spliter);
|
||||
})->pluck('match_id')->toArray()
|
||||
};
|
||||
}
|
||||
|
||||
Log::debug('matches_ids', $matches_ids);
|
||||
|
||||
$res = StatistikoPlayer::with('details')->whereIn('ss_player_id', $player_ids)->whereIn('match_id', $matches_ids)->get();
|
||||
$arr = [];
|
||||
$count = 0;
|
||||
$res = $this->getPlayers($part, $player_ids);
|
||||
foreach ($res as $val) {
|
||||
|
||||
$ss_player_id = (int) $val->ss_player_id;
|
||||
@@ -63,24 +34,15 @@ trait PlayerQuery
|
||||
$home_id = (int) $val->event->home_id;
|
||||
$away_id = (int) $val->event->away_id;
|
||||
|
||||
if ($ss_player_id == 1200574) {
|
||||
$count++;
|
||||
}
|
||||
|
||||
if (! isset($arr[$ss_player_id])) {
|
||||
self::array_template($arr, $ss_player_id);
|
||||
}
|
||||
|
||||
if ($activeteam_id == $home_id) {
|
||||
$arr[$ss_player_id]['events_played_home'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_home'] += $minutes_played;
|
||||
$arr[$ss_player_id]['events_played_home'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_home'] += $minutes_played;
|
||||
} elseif ($activeteam_id == $away_id) {
|
||||
$arr[$ss_player_id]['events_played_away'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_away'] += $minutes_played;
|
||||
$arr[$ss_player_id]['events_played_away'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_away'] += $minutes_played;
|
||||
}
|
||||
$cards = $val->card_yellow + $val->card_yellowred;
|
||||
|
||||
@@ -99,8 +61,6 @@ trait PlayerQuery
|
||||
$arr[$ss_player_id]['was_fouled'] += $val->was_fouled;
|
||||
}
|
||||
|
||||
// Log::debug('count 1200574', [$part => $count]);
|
||||
|
||||
foreach ($players as $player) {
|
||||
if (isset($arr[$player->ss_player_id])) {
|
||||
$arr[$player->ss_player_id]['position'] = $player->position;
|
||||
@@ -128,10 +88,8 @@ trait PlayerQuery
|
||||
$player_ids[] = $player->ss_player_id;
|
||||
}
|
||||
|
||||
$matches_ids = StatistikoEvent::where('league_id', $this->liga_id)->pluck('match_id')->toArray();
|
||||
$res = StatistikoPlayer::with('details')->whereIn('ss_player_id', $player_ids)->whereIn('match_id', $matches_ids)->get();
|
||||
|
||||
$arr = [];
|
||||
$res = $this->getPlayers(1, $player_ids);
|
||||
foreach ($res as $val) {
|
||||
|
||||
$ss_player_id = (int) $val->ss_player_id;
|
||||
@@ -141,19 +99,15 @@ trait PlayerQuery
|
||||
$away_id = (int) $val->event->away_id;
|
||||
|
||||
if (! isset($arr[$ss_player_id])) {
|
||||
self::array_template($arr, $ss_player_id);
|
||||
$this->array_template($arr, $ss_player_id);
|
||||
}
|
||||
|
||||
if ($activeteam_id == $home_id) {
|
||||
$arr[$ss_player_id]['events_played_home'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_home'] += $minutes_played;
|
||||
$arr[$ss_player_id]['events_played_home'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_home'] += $minutes_played;
|
||||
} elseif ($activeteam_id == $away_id) {
|
||||
$arr[$ss_player_id]['events_played_away'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_away'] += $minutes_played;
|
||||
$arr[$ss_player_id]['events_played_away'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_away'] += $minutes_played;
|
||||
}
|
||||
$cards = $val->card_yellow + $val->card_yellowred;
|
||||
|
||||
@@ -183,7 +137,7 @@ trait PlayerQuery
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public static function array_template(array &$arr, int $ss_player_id)
|
||||
public function array_template(array &$arr, int $ss_player_id)
|
||||
{
|
||||
$arr[$ss_player_id]['ss_player_id'] = 0;
|
||||
$arr[$ss_player_id]['total_events'] = 0;
|
||||
@@ -221,4 +175,40 @@ trait PlayerQuery
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public function getPlayers(int $part, array $player_ids)
|
||||
{
|
||||
switch ($this->season_or_date) {
|
||||
case 'season':
|
||||
if (! $this->season_selected) {
|
||||
$this->season_selected = $this->getCurrentSeason();
|
||||
}
|
||||
|
||||
return match ($part) {
|
||||
1 => StatistikoEvent::with('details')
|
||||
->whereIn('ss_player_id', $player_ids)
|
||||
->when($this->season_selected, function ($query) {
|
||||
return $query->whereIn('season', $this->season_selected);
|
||||
})->pluck('match_id')->toArray(),
|
||||
2 => StatistikoEvent::with('details')
|
||||
->whereIn('ss_player_id', $player_ids)
|
||||
->when($this->season_selected, function ($query) {
|
||||
return $query->whereNotIn('season', $this->season_selected);
|
||||
})->pluck('match_id')->toArray(),
|
||||
};
|
||||
default:
|
||||
return match ($part) {
|
||||
1 => StatistikoEvent::with('details')
|
||||
->whereIn('ss_player_id', $player_ids)
|
||||
->when($this->date_spliter, function ($query) {
|
||||
return $query->whereDate('starttime', '>', $this->date_spliter);
|
||||
})->pluck('match_id')->toArray(),
|
||||
2 => StatistikoEvent::with('details')
|
||||
->whereIn('ss_player_id', $player_ids)
|
||||
->when($this->season_selected, function ($query) {
|
||||
return $query->whereDate('starttime', '<=', $this->date_spliter);
|
||||
})->pluck('match_id')->toArray()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user