wip pp filter
This commit is contained in:
1 parent
fc1e1b2832
commit
55f31acf2a
23 files changed
+1127
-329
No files matched your search
@@ -16,8 +16,8 @@ class AverageLeagueSeason
|
||||
public static function load(array &$expectations, array $filter)
|
||||
{
|
||||
$tournament_id = (int) $filter['league_id'] ?? 0;
|
||||
$seasonmode = $filter['seasonmode'];
|
||||
$active_season = GetSeason::active($seasonmode);
|
||||
$season_mode = $filter['season_mode'];
|
||||
$active_season = GetSeason::active($season_mode);
|
||||
|
||||
$res = StatistikoEvent::where('league_id', $tournament_id)
|
||||
->when($active_season, function ($query) use ($active_season) {
|
||||
|
||||
@@ -22,14 +22,14 @@ class AverageTeam
|
||||
$season_or_date = $filter['season_or_date'] ?? 'season';
|
||||
$start = $filter['start_date'] ?? 0;
|
||||
$end = $filter['end_date'] ?? 0;
|
||||
$seasonmode = $filter['seasonmode'];
|
||||
$season_mode = $filter['season_mode'];
|
||||
|
||||
if ($season_or_date != 'season') {
|
||||
$season = 0;
|
||||
} else {
|
||||
$end = 0;
|
||||
$start = 0;
|
||||
$season = GetSeason::load($season, $seasonmode);
|
||||
$season = GetSeason::load($season, $season_mode);
|
||||
}
|
||||
|
||||
$res = StatistikoEvent::where('league_id', $tournament_id)
|
||||
|
||||
@@ -16,8 +16,8 @@ class AverageTeamSeason
|
||||
$tournament_id = (int) $filter['league_id'] ?? 0;
|
||||
$team_position = $filter['team_position'];
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
$seasonmode = $filter['seasonmode'];
|
||||
$season = GetSeason::active($seasonmode);
|
||||
$season_mode = $filter['season_mode'];
|
||||
$season = GetSeason::active($season_mode);
|
||||
|
||||
$res = StatistikoEvent::where('league_id', $tournament_id)
|
||||
->when($season, function ($query) use ($season) {
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\Boxes;
|
||||
|
||||
use App\Models\StatistikoDetail;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
|
||||
class LoadPlayerAverages
|
||||
{
|
||||
public static function load(int &$team_id, string|array $season)
|
||||
{
|
||||
// dd($team_id);
|
||||
|
||||
$players = StatistikoDetail::where('ss_team_id', $team_id)->where('is_active', 1)->get();
|
||||
|
||||
$player_ids = [];
|
||||
foreach ($players as $player) {
|
||||
$player_ids[] = $player->ss_player_id;
|
||||
}
|
||||
|
||||
$arr = [];
|
||||
|
||||
if (is_array($season)) {
|
||||
$matches_for_season = StatistikoEvent::whereIn('season', $season)->pluck('match_id')->toArray();
|
||||
$res = StatistikoPlayer::with('details')->whereIn('match_id', $matches_for_season)->whereIn('ss_player_id', $player_ids)->get();
|
||||
} else {
|
||||
$res = StatistikoPlayer::with('details')->whereIn('ss_player_id', $player_ids)->get();
|
||||
}
|
||||
|
||||
foreach ($res as $val) {
|
||||
|
||||
$ss_player_id = (int) $val->ss_player_id;
|
||||
$activeteam_id = (int) $val->activeteam_id;
|
||||
$minutes_played = (int) $val->minutes_played;
|
||||
$home_id = (int) $val->event->home_id;
|
||||
$away_id = (int) $val->event->away_id;
|
||||
$startime = $val->event->starttime;
|
||||
|
||||
if ($startime->greaterThan(now()->subDays(180))) {
|
||||
$last_180_days = true;
|
||||
} else {
|
||||
$last_180_days = false;
|
||||
}
|
||||
|
||||
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;
|
||||
if ($last_180_days) {
|
||||
$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;
|
||||
if ($last_180_days) {
|
||||
$arr[$ss_player_id]['events_played_away'] += 1;
|
||||
$arr[$ss_player_id]['minutes_played_away'] += $minutes_played;
|
||||
}
|
||||
|
||||
}
|
||||
$cards = $val->card_yellow + $val->card_yellowred;
|
||||
|
||||
if ($season == 'last180days' && $last_180_days) {
|
||||
$arr[$ss_player_id]['ss_player_id'] = $ss_player_id;
|
||||
$arr[$ss_player_id]['total_events']++;
|
||||
$arr[$ss_player_id]['total_min'] += $minutes_played;
|
||||
$arr[$ss_player_id]['average_min'] = round($arr[$ss_player_id]['total_min'] / $arr[$ss_player_id]['total_events']);
|
||||
$arr[$ss_player_id]['goals'] += $val->goals;
|
||||
$arr[$ss_player_id]['fouls'] += $val->fouls;
|
||||
$arr[$ss_player_id]['cards'] += $cards;
|
||||
$arr[$ss_player_id]['offsides'] += $val->offsides;
|
||||
$arr[$ss_player_id]['shots_on_target'] += $val->shots_on_target;
|
||||
$arr[$ss_player_id]['shots_off_target'] += $val->shots_off_target;
|
||||
$arr[$ss_player_id]['shots_blocked'] += $val->shots_blocked;
|
||||
$arr[$ss_player_id]['total_shots'] += $val->shots_on_target + $val->shots_off_target + $val->shots_blocked;
|
||||
}
|
||||
if ($season != 'last180days') {
|
||||
$arr[$ss_player_id]['ss_player_id'] = $ss_player_id;
|
||||
$arr[$ss_player_id]['total_events']++;
|
||||
$arr[$ss_player_id]['total_min'] += $minutes_played;
|
||||
$arr[$ss_player_id]['average_min'] = round($arr[$ss_player_id]['total_min'] / $arr[$ss_player_id]['total_events']);
|
||||
$arr[$ss_player_id]['goals'] += $val->goals;
|
||||
$arr[$ss_player_id]['fouls'] += $val->fouls;
|
||||
$arr[$ss_player_id]['cards'] += $cards;
|
||||
$arr[$ss_player_id]['offsides'] += $val->offsides;
|
||||
$arr[$ss_player_id]['shots_on_target'] += $val->shots_on_target;
|
||||
$arr[$ss_player_id]['shots_off_target'] += $val->shots_off_target;
|
||||
$arr[$ss_player_id]['shots_blocked'] += $val->shots_blocked;
|
||||
$arr[$ss_player_id]['total_shots'] += $val->shots_on_target + $val->shots_off_target + $val->shots_blocked;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($players as $value) {
|
||||
if (isset($arr[$value->ss_player_id])) {
|
||||
$arr[$value->ss_player_id]['position'] = $value->position;
|
||||
$arr[$value->ss_player_id]['player_name'] = $value->player_name;
|
||||
$arr[$value->ss_player_id]['preferred_foot'] = $value->preferred_foot;
|
||||
}
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public static function array_template(array &$arr, int $ss_player_id)
|
||||
{
|
||||
$arr[$ss_player_id]['ss_player_id'] = 0;
|
||||
$arr[$ss_player_id]['total_events'] = 0;
|
||||
$arr[$ss_player_id]['total_min'] = 0;
|
||||
$arr[$ss_player_id]['average_min'] = 0;
|
||||
$arr[$ss_player_id]['events_played_home'] = 0;
|
||||
$arr[$ss_player_id]['events_played_away'] = 0;
|
||||
$arr[$ss_player_id]['minutes_played_home'] = 0;
|
||||
$arr[$ss_player_id]['minutes_played_away'] = 0;
|
||||
$arr[$ss_player_id]['goals'] = 0;
|
||||
$arr[$ss_player_id]['fouls'] = 0;
|
||||
$arr[$ss_player_id]['offsides'] = 0;
|
||||
$arr[$ss_player_id]['shots_on_target'] = 0;
|
||||
$arr[$ss_player_id]['shots_off_target'] = 0;
|
||||
$arr[$ss_player_id]['shots_blocked'] = 0;
|
||||
$arr[$ss_player_id]['total_shots'] = 0;
|
||||
$arr[$ss_player_id]['cards'] = 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user