wip
This commit is contained in:
1 parent
15de6feee8
commit
3971dcdb13
1 file changed
+36
-17
@@ -109,13 +109,15 @@ class LoadPerformance
|
||||
}
|
||||
}
|
||||
|
||||
$res = StatistikoPlayer::whereIn('match_id', $home_matches)->select('match_id', 'minutes_played', 'playerrating_value', 'player_position')->get();
|
||||
$homes = self::filterMatches($res, $home_matches);
|
||||
$res = StatistikoPlayer::whereIn('match_id', $home_matches)->select('match_id', 'ss_player_id', 'activeteam_id', 'minutes_played', 'playerrating_value', 'player_position')->get();
|
||||
$homes = self::filterMatches($res, $home_matches, $home_id);
|
||||
|
||||
// dd($homes);
|
||||
// dd($homes['all']);
|
||||
|
||||
$res = StatistikoPlayer::whereIn('match_id', $away_matches)->select('match_id', 'minutes_played', 'playerrating_value', 'player_position')->get();
|
||||
$aways = self::filterMatches($res, $away_matches);
|
||||
$res = StatistikoPlayer::whereIn('match_id', $away_matches)->select('match_id', 'ss_player_id', 'activeteam_id', 'minutes_played', 'playerrating_value', 'player_position')->get();
|
||||
$aways = self::filterMatches($res, $away_matches, $away_id);
|
||||
|
||||
// dd($aways['all']);
|
||||
|
||||
$c_home = isset($homes['all']) ? count($homes['all']) : 0;
|
||||
$c_away = isset($aways['all']) ? count($aways['all']) : 0;
|
||||
@@ -127,7 +129,7 @@ class LoadPerformance
|
||||
$away_av = self::makeAv($aways, $length);
|
||||
|
||||
|
||||
$res = StatistikoPlayer::whereIn('match_id', $league_matches)->select('match_id', 'minutes_played', 'playerrating_value', 'player_position')->get();
|
||||
$res = StatistikoPlayer::whereIn('match_id', $league_matches)->select('match_id', 'ss_player_id', 'activeteam_id', 'minutes_played', 'playerrating_value', 'player_position')->get();
|
||||
$league = self::filterMatches($res, $league_matches);
|
||||
$league_av = self::leagueAv($league, $length);
|
||||
|
||||
@@ -423,7 +425,7 @@ class LoadPerformance
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function filterMatches($res, array $matches)
|
||||
public static function filterMatches($res, array $matches, $team_id = 0)
|
||||
{
|
||||
if (!$res->count()) {
|
||||
return ['all', 'def', 'att', 'mid'];
|
||||
@@ -432,52 +434,69 @@ class LoadPerformance
|
||||
$result = [];
|
||||
foreach ($res as $value) {
|
||||
|
||||
// dd($value);
|
||||
|
||||
$match_id = $value->match_id;
|
||||
|
||||
if (! isset($result[$match_id])) {
|
||||
$result[$match_id]['all']['ply'] = 0;
|
||||
$result[$match_id]['all']['sum_min'] = 0;
|
||||
$result[$match_id]['all']['rating'] = 0;
|
||||
|
||||
$result[$match_id]['att']['ply'] = 0;
|
||||
$result[$match_id]['att']['sum_min'] = 0;
|
||||
$result[$match_id]['att']['rating'] = 0;
|
||||
|
||||
$result[$match_id]['mid']['ply'] = 0;
|
||||
$result[$match_id]['mid']['sum_min'] = 0;
|
||||
$result[$match_id]['mid']['rating'] = 0;
|
||||
|
||||
$result[$match_id]['def']['ply'] = 0;
|
||||
$result[$match_id]['def']['sum_min'] = 0;
|
||||
$result[$match_id]['def']['rating'] = 0;
|
||||
}
|
||||
|
||||
if (0 == $team_id || $value->activeteam_id == $team_id) {
|
||||
|
||||
if ($value->minutes_played > 0) {
|
||||
|
||||
$result[$match_id]['all']['ply']++;
|
||||
$result[$match_id]['all']['sum_min'] += (int) $value->minutes_played;
|
||||
$result[$match_id]['all']['rating'] += (float) $value->playerrating_value * (int) $value->minutes_played;
|
||||
$result[$match_id]['all']['rating'] += (float) $value->playerrating_value;
|
||||
|
||||
if ($value->player_position == 'M') {
|
||||
$result[$match_id]['mid']['ply']++;
|
||||
$result[$match_id]['mid']['sum_min'] += (int) $value->minutes_played;
|
||||
$result[$match_id]['mid']['rating'] += (float) $value->playerrating_value * (int) $value->minutes_played;
|
||||
$result[$match_id]['mid']['rating'] += (float) $value->playerrating_value;
|
||||
} elseif ($value->player_position == 'F') {
|
||||
$result[$match_id]['att']['ply']++;
|
||||
$result[$match_id]['att']['sum_min'] += (int) $value->minutes_played;
|
||||
$result[$match_id]['att']['rating'] += (float) $value->playerrating_value * (int) $value->minutes_played;
|
||||
$result[$match_id]['att']['rating'] += (float) $value->playerrating_value;
|
||||
} elseif ($value->player_position == 'D') {
|
||||
$result[$match_id]['def']['ply']++;
|
||||
$result[$match_id]['def']['sum_min'] += (int) $value->minutes_played;
|
||||
$result[$match_id]['def']['rating'] += (float) $value->playerrating_value * (int) $value->minutes_played;
|
||||
$result[$match_id]['def']['rating'] += (float) $value->playerrating_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// dd($result);
|
||||
|
||||
$return = [];
|
||||
foreach ($matches as $matchid) {
|
||||
if (isset($result[$matchid])) {
|
||||
$return['all'][] = round($result[$matchid]['all']['rating'] / $result[$matchid]['all']['sum_min'], 1);
|
||||
$return['all'][] = round($result[$matchid]['all']['rating'] / $result[$matchid]['all']['ply'], 1);
|
||||
if ($result[$matchid]['def']['sum_min']) {
|
||||
$return['def'][] = round($result[$matchid]['def']['rating'] / $result[$matchid]['def']['sum_min'], 1);
|
||||
$return['def'][] = round($result[$matchid]['def']['rating'] / $result[$matchid]['def']['ply'], 1);
|
||||
} else {
|
||||
$return['def'][] = null;
|
||||
}
|
||||
if ($result[$matchid]['att']['sum_min']) {
|
||||
$return['att'][] = round($result[$matchid]['att']['rating'] / $result[$matchid]['att']['sum_min'], 1);
|
||||
$return['att'][] = round($result[$matchid]['att']['rating'] / $result[$matchid]['att']['ply'], 1);
|
||||
} else {
|
||||
$return['att'][] = null;
|
||||
}
|
||||
if ($result[$matchid]['mid']['sum_min']) {
|
||||
$return['mid'][] = round($result[$matchid]['mid']['rating'] / $result[$matchid]['mid']['sum_min'], 1);
|
||||
$return['mid'][] = round($result[$matchid]['mid']['rating'] / $result[$matchid]['mid']['ply'], 1);
|
||||
} else {
|
||||
$return['mid'][] = null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user