wip
This commit is contained in:
1 parent
377478d9e8
commit
8a5b03eec4
3 files changed
+64
-60
No files matched your search
@@ -18,10 +18,8 @@ class LoadEvents
|
||||
$match_id = (int) $filter['match_id'] ?? 0;
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
$season_or_date = $filter['season_or_date'] ?? 'season';
|
||||
$ss_player_id = (int) $filter['ss_player_id'] ?? 0;
|
||||
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
||||
$team_position = $filter['team_position'];
|
||||
$player_on_field = $filter['player_on_field'] ?? 'all';
|
||||
$accuracy = (float) $filter['accuracy'] ?? 0.5;
|
||||
$similar_past_matches = $filter['similar_past_matches'];
|
||||
|
||||
@@ -76,56 +74,12 @@ class LoadEvents
|
||||
$away_team = 'Against';
|
||||
}
|
||||
|
||||
/**
|
||||
* IF WITH PLAYER
|
||||
*/
|
||||
$matches_played = [];
|
||||
$description = '';
|
||||
|
||||
if ($ss_player_id) {
|
||||
$matches_season = StatistikoEvent::where(function ($query) use ($team_id, $team_position) {
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('home_id', '=', $team_id);
|
||||
case 'away':
|
||||
return $query->where('away_id', '=', $team_id);
|
||||
default:
|
||||
return $query->where('home_id', '=', $team_id)
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})->pluck('match_id')->toArray();
|
||||
|
||||
$matches_played = StatistikoPlayer::query()
|
||||
->whereIn('match_id', $matches_season)
|
||||
->where('ss_player_id', $ss_player_id)
|
||||
->when($player_on_field, function ($query) use ($player_on_field) {
|
||||
// 'all' => 'All',
|
||||
// 'lineup' => 'Lineup',
|
||||
// 'substituted' => 'Substituted',
|
||||
// 'notplayed' => 'Not Played',
|
||||
switch ($player_on_field) {
|
||||
case 'all':
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
case 'lineup':
|
||||
return $query->where('lineup', 'T')->where('minutes_played', '>', 0);
|
||||
case 'substituted':
|
||||
return $query->where('lineup', 'P')->where('minutes_played', '>', 0);
|
||||
default:
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
}
|
||||
})
|
||||
->pluck('match_id')->toArray();
|
||||
|
||||
if (! $matches_played) {
|
||||
$matches_played[] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
$match = StatisticFixtures::where('id', $match_id)->first();
|
||||
/**
|
||||
* STATTISTIC DATA
|
||||
*/
|
||||
$res = LoadEventsQuery::load($filter, $matches_played, $handicap_range, $total_range, $match);
|
||||
$res = LoadEventsQuery::load($filter, $handicap_range, $total_range, $match);
|
||||
|
||||
|
||||
$dataset_home = [];
|
||||
$dataset_away = [];
|
||||
@@ -137,11 +91,8 @@ class LoadEvents
|
||||
$events = [];
|
||||
$results = ['w' => 0, 'd' => 0, 'l' => 0, 'w2' => 0, 'l2' => 0];
|
||||
|
||||
if (!\in_array($team_position, ['home', 'away']))
|
||||
if (!$team_id || !\in_array($team_position, ['home', 'away'])) {
|
||||
$team_position = 'all';
|
||||
|
||||
if (!isset($res[$team_position])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$expectations = LoadExpectations::load($res['all'], $match, $statistic_type);
|
||||
|
||||
@@ -3,19 +3,22 @@
|
||||
namespace App\Filament\Widgets\Data\LoadEvents;
|
||||
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
|
||||
class LoadEventsQuery
|
||||
{
|
||||
public static function load(array $filter, array $matches_played, array $handicap_range, array $total_range, object $match)
|
||||
public static function load(array $filter, array $handicap_range, array $total_range, object $match)
|
||||
{
|
||||
$league_id = (int) $filter['league_id'] ?? 0;
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
$season = $filter['season'] ?? 0;
|
||||
$start = $filter['start_date'] ?? 0;
|
||||
$end = $filter['end_date'] ?? 0;
|
||||
$ss_player_id = (int) $filter['ss_player_id'] ?? 0;
|
||||
$player_on_field = $filter['player_on_field'] ?? 'all';
|
||||
$similar_past_matches = $filter['similar_past_matches'];
|
||||
$statistic_type = $filter['statistic_type'] ?? 'gls';
|
||||
$team_position = $filter['team_position'];
|
||||
$home_id = $match->home_id;
|
||||
$away_id = $match->away_id;
|
||||
|
||||
@@ -23,6 +26,50 @@ class LoadEventsQuery
|
||||
$statistic_type = 'gls';
|
||||
}
|
||||
|
||||
/**
|
||||
* IF WITH PLAYER
|
||||
*/
|
||||
$matches_played = [];
|
||||
|
||||
if ($ss_player_id) {
|
||||
$matches_season = StatistikoEvent::where(function ($query) use ($team_id, $team_position) {
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('home_id', '=', $team_id);
|
||||
case 'away':
|
||||
return $query->where('away_id', '=', $team_id);
|
||||
default:
|
||||
return $query->where('home_id', '=', $team_id)
|
||||
->orWhere('away_id', '=', $team_id);
|
||||
}
|
||||
})->pluck('match_id')->toArray();
|
||||
|
||||
$matches_played = StatistikoPlayer::query()
|
||||
->whereIn('match_id', $matches_season)
|
||||
->where('ss_player_id', $ss_player_id)
|
||||
->when($player_on_field, function ($query) use ($player_on_field) {
|
||||
// 'all' => 'All',
|
||||
// 'lineup' => 'Lineup',
|
||||
// 'substituted' => 'Substituted',
|
||||
// 'notplayed' => 'Not Played',
|
||||
switch ($player_on_field) {
|
||||
case 'all':
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
case 'lineup':
|
||||
return $query->where('lineup', 'T')->where('minutes_played', '>', 0);
|
||||
case 'substituted':
|
||||
return $query->where('lineup', 'P')->where('minutes_played', '>', 0);
|
||||
default:
|
||||
return $query->where('minutes_played', '>', 0);
|
||||
}
|
||||
})
|
||||
->pluck('match_id')->toArray();
|
||||
|
||||
if (! $matches_played) {
|
||||
$matches_played[] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* STATTISTIC DATA
|
||||
*/
|
||||
@@ -61,6 +108,8 @@ class LoadEventsQuery
|
||||
->orderBy('starttime', 'ASC')
|
||||
->get();
|
||||
|
||||
// dd($res);
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $value) {
|
||||
$tmp = [];
|
||||
|
||||
@@ -44,6 +44,7 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
$statistic_type = HelperStatisticType::get($this->filters);
|
||||
|
||||
if (! isset($data['datasets'][0])) {
|
||||
@@ -124,6 +125,15 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
}
|
||||
|
||||
$boxes = [];
|
||||
|
||||
// BOX 6
|
||||
$boxes[] = Stat::make($statistic_type, self::template('expectations_home', 'expectations_away', 'Home', 'Away', $expectations_home, $expectations_away))
|
||||
->description('Expected Values')
|
||||
->extraAttributes([
|
||||
'class' => 'box-yellow',
|
||||
]);
|
||||
|
||||
if ($team_id) {
|
||||
// BOX 1
|
||||
$boxes[] = Stat::make('Total', new HtmlString('<div id="number-of-events">' . $total_home . '</div>'))
|
||||
->description('Events')
|
||||
@@ -164,13 +174,7 @@ class StatsMedianAverage extends StatsOverviewWidget
|
||||
'class' => 'box-purple',
|
||||
]);
|
||||
// ->extraAttributes(['x-init' => "animate('mehome', $median_home); animate('meaway', $median_away, 0)"]);
|
||||
|
||||
// BOX 6
|
||||
$boxes[] = Stat::make($statistic_type, self::template('expectations_home', 'expectations_away', 'Home', 'Away', $expectations_home, $expectations_away))
|
||||
->description('Expected Values')
|
||||
->extraAttributes([
|
||||
'class' => 'box-yellow',
|
||||
]);
|
||||
}
|
||||
|
||||
$this->columns = [
|
||||
'default' => 1,
|
||||
|
||||
Reference in new issue
Block a user