wip
This commit is contained in:
1 parent
7e9a4e87dd
commit
6d5b05e561
1 file changed
+100
-17
@@ -42,6 +42,7 @@ class LoadPerformance
|
||||
$labels = [];
|
||||
foreach ($res as $val) {
|
||||
if ($val->home_id == $home_id or $val->away_id == $home_id or $val->home_id == $away_id or $val->away_id == $away_id) {
|
||||
|
||||
$labels[] = round($val->starttime->diffInDays(Carbon::now()));
|
||||
$label_formatted[$val->match_id] = $val->starttime->format('d. F Y H:i');
|
||||
|
||||
@@ -58,32 +59,77 @@ class LoadPerformance
|
||||
}
|
||||
}
|
||||
|
||||
$res = StatistikoPlayer::whereIn('match_id', $home_matches)->select('match_id', 'minutes_played', 'playerrating_value')->get();
|
||||
$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', $away_matches)->select('match_id', 'minutes_played', 'playerrating_value')->get();
|
||||
$res = StatistikoPlayer::whereIn('match_id', $away_matches)->select('match_id', 'minutes_played', 'playerrating_value', 'player_position')->get();
|
||||
$aways = self::filterMatches($res, $away_matches);
|
||||
|
||||
$data = [
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => $match->home->name,
|
||||
'data' => $homes,
|
||||
'data' => $homes['all'],
|
||||
'spanGaps' => true,
|
||||
'tension' => 0.5,
|
||||
'borderColor' => '#fb2c36',
|
||||
'fill' => [
|
||||
'target' => 1,
|
||||
'above' => '#fb2c3680',
|
||||
'below' => '#fdc70080',
|
||||
],
|
||||
'backgroundColor' => '#c10007',
|
||||
],
|
||||
[
|
||||
'label' => 'Defence',
|
||||
'data' => $homes['def'],
|
||||
'spanGaps' => true,
|
||||
'tension' => 0.5,
|
||||
'borderColor' => '#c10007',
|
||||
'fill' => false,
|
||||
],
|
||||
[
|
||||
'label' => 'Attak',
|
||||
'data' => $homes['att'],
|
||||
'spanGaps' => true,
|
||||
'tension' => 0.5,
|
||||
'borderColor' => '#c10007',
|
||||
'fill' => false,
|
||||
],
|
||||
[
|
||||
'label' => 'Midfield',
|
||||
'data' => $homes['mid'],
|
||||
'spanGaps' => true,
|
||||
'tension' => 0.5,
|
||||
'borderColor' => '#c10007',
|
||||
'fill' => false,
|
||||
],
|
||||
[
|
||||
'label' => $match->away->name,
|
||||
'data' => $aways,
|
||||
'data' => $aways['all'],
|
||||
'spanGaps' => true,
|
||||
'tension' => 0.5,
|
||||
'borderColor' => '#fdc700',
|
||||
'backgroundColor' => '#a65f00',
|
||||
'fill' => false,
|
||||
],
|
||||
[
|
||||
'label' => 'Defence',
|
||||
'data' => $aways['def'],
|
||||
'spanGaps' => true,
|
||||
'tension' => 0.5,
|
||||
'borderColor' => '#d08700',
|
||||
'fill' => false,
|
||||
],
|
||||
[
|
||||
'label' => 'Attak',
|
||||
'data' => $aways['att'],
|
||||
'spanGaps' => true,
|
||||
'tension' => 0.5,
|
||||
'borderColor' => '#d08700',
|
||||
'fill' => false,
|
||||
],
|
||||
[
|
||||
'label' => 'Midfield',
|
||||
'data' => $aways['mid'],
|
||||
'spanGaps' => true,
|
||||
'tension' => 0.5,
|
||||
'borderColor' => '#d08700',
|
||||
'fill' => false,
|
||||
],
|
||||
],
|
||||
@@ -122,22 +168,59 @@ class LoadPerformance
|
||||
{
|
||||
$result = [];
|
||||
foreach ($res as $value) {
|
||||
|
||||
$match_id = $value->match_id;
|
||||
if (isset($return[$match_id])) {
|
||||
$result[$match_id]['sum_min'] += $value->minutes_played;
|
||||
$result[$match_id]['rating'] += $value->playerrating_value * $value->minutes_played;
|
||||
} else {
|
||||
$result[$match_id]['sum_min'] = $value->minutes_played;
|
||||
$result[$match_id]['rating'] = $value->playerrating_value * $value->minutes_played;
|
||||
|
||||
if (! isset($result[$match_id])) {
|
||||
$result[$match_id]['all']['sum_min'] = 0;
|
||||
$result[$match_id]['all']['rating'] = 0;
|
||||
$result[$match_id]['att']['sum_min'] = 0;
|
||||
$result[$match_id]['att']['rating'] = 0;
|
||||
$result[$match_id]['mid']['sum_min'] = 0;
|
||||
$result[$match_id]['mid']['rating'] = 0;
|
||||
$result[$match_id]['def']['sum_min'] = 0;
|
||||
$result[$match_id]['def']['rating'] = 0;
|
||||
}
|
||||
|
||||
$result[$match_id]['all']['sum_min'] += $value->minutes_played;
|
||||
$result[$match_id]['all']['rating'] += $value->playerrating_value * $value->minutes_played;
|
||||
|
||||
if ($value->player_position == 'M') {
|
||||
$result[$match_id]['mid']['sum_min'] += $value->minutes_played;
|
||||
$result[$match_id]['mid']['rating'] += $value->playerrating_value * $value->minutes_played;
|
||||
} elseif ($value->player_position == 'A') {
|
||||
$result[$match_id]['att']['sum_min'] += $value->minutes_played;
|
||||
$result[$match_id]['att']['rating'] += $value->playerrating_value * $value->minutes_played;
|
||||
} elseif ($value->player_position == 'D') {
|
||||
$result[$match_id]['def']['sum_min'] += $value->minutes_played;
|
||||
$result[$match_id]['def']['rating'] += $value->playerrating_value * $value->minutes_played;
|
||||
}
|
||||
}
|
||||
|
||||
$return = [];
|
||||
foreach ($matches as $matchid) {
|
||||
if (isset($result[$matchid])) {
|
||||
$return[] = $result[$matchid]['rating'] / $result[$matchid]['sum_min'];
|
||||
$return['all'][] = $result[$matchid]['all']['rating'] / $result[$matchid]['all']['sum_min'];
|
||||
if ($result[$matchid]['def']['sum_min']) {
|
||||
$return['def'][] = $result[$matchid]['def']['rating'] / $result[$matchid]['def']['sum_min'];
|
||||
} else {
|
||||
$return['def'][] = null;
|
||||
}
|
||||
if ($result[$matchid]['att']['sum_min']) {
|
||||
$return['att'][] = $result[$matchid]['att']['rating'] / $result[$matchid]['att']['sum_min'];
|
||||
} else {
|
||||
$return['att'][] = null;
|
||||
}
|
||||
if ($result[$matchid]['mid']['sum_min']) {
|
||||
$return['mid'][] = $result[$matchid]['mid']['rating'] / $result[$matchid]['mid']['sum_min'];
|
||||
} else {
|
||||
$return['mid'][] = null;
|
||||
}
|
||||
} else {
|
||||
$return[] = null;
|
||||
$return['all'][] = null;
|
||||
$return['def'][] = null;
|
||||
$return['att'][] = null;
|
||||
$return['mid'][] = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user