wip
This commit is contained in:
1 parent
2734b06350
commit
fbaadcd248
9 files changed
+213
-219
No files matched your search
@@ -2,15 +2,14 @@
|
||||
|
||||
namespace App\Filament\Widgets\Data;
|
||||
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
|
||||
class EventsLoadAspGoal
|
||||
class LoadEventsAspGoal
|
||||
{
|
||||
public static function load($filter)
|
||||
{
|
||||
// dd($filter);
|
||||
dd($filter);
|
||||
|
||||
$league_id = (int) $filter['league_id'] ?? 0;
|
||||
|
||||
@@ -23,27 +22,41 @@ class EventsLoadAspGoal
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* WITH PLAYER
|
||||
*/
|
||||
$tm_player_id = $filter['tm_player_id'];
|
||||
|
||||
if ($tm_player_id) {
|
||||
$matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id)->pluck('match_id')->toArray();
|
||||
} else {
|
||||
$matches_played = false;
|
||||
}
|
||||
|
||||
$team_position = $filter['team_position'];
|
||||
|
||||
/**
|
||||
* ACCURACY DATA
|
||||
* STATTISTIC DATA
|
||||
*/
|
||||
switch ($filter['team_position']) {
|
||||
case 'home':
|
||||
$res = StatisticFixtures::where('league_id', $league_id)->where('home_id', $team_id)->first();
|
||||
break;
|
||||
|
||||
case 'away':
|
||||
$res = StatisticFixtures::where('league_id', $league_id)->where('away_id', $team_id)->first();
|
||||
break;
|
||||
|
||||
default:
|
||||
$res = StatisticFixtures::where('league_id', $league_id)
|
||||
->where(function ($query) use ($team_id) {
|
||||
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
})->first();
|
||||
break;
|
||||
}
|
||||
$res = StatistikoEvent::where('league_id', $league_id)
|
||||
->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);
|
||||
}
|
||||
})
|
||||
->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})->first();
|
||||
|
||||
$start = $filter['start_date'] ?? 0;
|
||||
|
||||
@@ -81,63 +94,84 @@ class EventsLoadAspGoal
|
||||
|
||||
$similar_past_matches = $filter['similar_past_matches'] ?? 0;
|
||||
|
||||
switch ($similar_past_matches) {
|
||||
case 'league':
|
||||
$res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
||||
$res = StatistikoEvent::when($league_id, function ($query) use ($league_id, $similar_past_matches) {
|
||||
switch ($similar_past_matches) {
|
||||
case 'league':
|
||||
return $query->where('league_id', $league_id);
|
||||
})->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($handicap_range, function ($query) use ($handicap_range) {
|
||||
default:
|
||||
return $query->whereBetween('exp_handicap', $handicap_range);
|
||||
})->when($total_range, function ($query) use ($total_range) {
|
||||
return $query->whereBetween('exp_total', $total_range);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
break;
|
||||
case 'all':
|
||||
$res = StatistikoEvent::when($handicap_range, function ($query) use ($handicap_range) {
|
||||
return $query->whereBetween('exp_handicap', $handicap_range);
|
||||
})->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($total_range, function ($query) use ($total_range) {
|
||||
return $query->whereBetween('exp_total', $total_range);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})
|
||||
->get();
|
||||
})->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($handicap_range, function ($query) use ($handicap_range) {
|
||||
return $query->whereBetween('exp_handicap', $handicap_range);
|
||||
})->when($total_range, function ($query) use ($total_range) {
|
||||
return $query->whereBetween('exp_total', $total_range);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})
|
||||
->get();
|
||||
|
||||
break;
|
||||
// case 'none':
|
||||
// $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
||||
// return $query->where('league_id', $league_id);
|
||||
// })->when($team_id, function ($query) use ($team_id, $team_position) {
|
||||
// switch ($team_position) {
|
||||
// case 'home':
|
||||
// return $query->where('home_id', $team_id);
|
||||
// break;
|
||||
// case 'away':
|
||||
// return $query->where('away_id', $team_id);
|
||||
// break;
|
||||
// default:
|
||||
// return $query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
// break;
|
||||
// }
|
||||
// })->when($start, function ($query) use ($start) {
|
||||
// return $query->where('starttime', '>=', $start);
|
||||
// })->when($end, function ($query) use ($end) {
|
||||
// return $query->where('starttime', '<=', $end);
|
||||
// })
|
||||
// ->get();
|
||||
// switch ($similar_past_matches) {
|
||||
// case 'league':
|
||||
// $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
||||
// return $query->where('league_id', $league_id);
|
||||
// })->when($matches_played, function ($query) use ($matches_played) {
|
||||
// return $query->whereIn('match_id', $matches_played);
|
||||
// })->when($handicap_range, function ($query) use ($handicap_range) {
|
||||
// return $query->whereBetween('exp_handicap', $handicap_range);
|
||||
// })->when($total_range, function ($query) use ($total_range) {
|
||||
// return $query->whereBetween('exp_total', $total_range);
|
||||
// })->when($start, function ($query) use ($start) {
|
||||
// return $query->where('starttime', '>=', $start);
|
||||
// })->when($end, function ($query) use ($end) {
|
||||
// return $query->where('starttime', '<=', $end);
|
||||
// })
|
||||
// ->get();
|
||||
|
||||
// break;
|
||||
}
|
||||
// break;
|
||||
// case 'all':
|
||||
// $res = StatistikoEvent::when($handicap_range, function ($query) use ($handicap_range) {
|
||||
// return $query->whereBetween('exp_handicap', $handicap_range);
|
||||
// })->when($matches_played, function ($query) use ($matches_played) {
|
||||
// return $query->whereIn('match_id', $matches_played);
|
||||
// })->when($total_range, function ($query) use ($total_range) {
|
||||
// return $query->whereBetween('exp_total', $total_range);
|
||||
// })->when($start, function ($query) use ($start) {
|
||||
// return $query->where('starttime', '>=', $start);
|
||||
// })->when($end, function ($query) use ($end) {
|
||||
// return $query->where('starttime', '<=', $end);
|
||||
// })
|
||||
// ->get();
|
||||
|
||||
// break;
|
||||
// // case 'none':
|
||||
// // $res = StatistikoEvent::when($league_id, function ($query) use ($league_id) {
|
||||
// // return $query->where('league_id', $league_id);
|
||||
// // })->when($team_id, function ($query) use ($team_id, $team_position) {
|
||||
// // switch ($team_position) {
|
||||
// // case 'home':
|
||||
// // return $query->where('home_id', $team_id);
|
||||
// // break;
|
||||
// // case 'away':
|
||||
// // return $query->where('away_id', $team_id);
|
||||
// // break;
|
||||
// // default:
|
||||
// // return $query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
// // break;
|
||||
// // }
|
||||
// // })->when($start, function ($query) use ($start) {
|
||||
// // return $query->where('starttime', '>=', $start);
|
||||
// // })->when($end, function ($query) use ($end) {
|
||||
// // return $query->where('starttime', '<=', $end);
|
||||
// // })
|
||||
// // ->get();
|
||||
|
||||
// // break;
|
||||
// }
|
||||
|
||||
$datasets = [];
|
||||
$labels = [];
|
||||
|
||||
+39
-81
@@ -2,11 +2,10 @@
|
||||
|
||||
namespace App\Filament\Widgets\Data;
|
||||
|
||||
use App\Models\StatisticFixtures;
|
||||
use App\Models\StatistikoEvent;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class EventsLoad
|
||||
class LoadEvents
|
||||
{
|
||||
public static $last_query = [];
|
||||
|
||||
@@ -14,12 +13,24 @@ class EventsLoad
|
||||
{
|
||||
// dd($filter);
|
||||
|
||||
if (self::$last_query) {
|
||||
return self::$last_query;
|
||||
}
|
||||
|
||||
$league_id = (int) $filter['league_id'] ?? 0;
|
||||
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
|
||||
$tm_player_id = (int) $filter['tm_player_id'] ?? 0;
|
||||
|
||||
$start = $filter['start_date'] ?? 0;
|
||||
|
||||
$end = $filter['end_date'] ?? 0;
|
||||
|
||||
$similar_past_matches = $filter['similar_past_matches'] ?? 0;
|
||||
|
||||
$statistic_type = $filter['statistic_type'] ?? 0;
|
||||
|
||||
if (! $league_id) {
|
||||
return [];
|
||||
}
|
||||
@@ -29,89 +40,34 @@ class EventsLoad
|
||||
|
||||
$team_position = $filter['team_position'];
|
||||
|
||||
/**
|
||||
* ACCURACY DATA
|
||||
*/
|
||||
switch ($filter['team_position']) {
|
||||
case 'home':
|
||||
$res = StatisticFixtures::where('league_id', $league_id)->where('home_id', $team_id)->first();
|
||||
break;
|
||||
|
||||
case 'away':
|
||||
$res = StatisticFixtures::where('league_id', $league_id)->where('away_id', $team_id)->first();
|
||||
break;
|
||||
|
||||
default:
|
||||
$res = StatisticFixtures::where('league_id', $league_id)
|
||||
->where(function ($query) use ($team_id) {
|
||||
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
})->first();
|
||||
break;
|
||||
}
|
||||
|
||||
$start = $filter['start_date'] ?? 0;
|
||||
|
||||
$end = $filter['end_date'] ?? 0;
|
||||
|
||||
$similar_past_matches = $filter['similar_past_matches'] ?? 0;
|
||||
|
||||
$statistic_type = $filter['statistic_type'] ?? 0;
|
||||
|
||||
/**
|
||||
* WITH PLAYER
|
||||
*/
|
||||
$tm_player_id = $filter['tm_player_id'];
|
||||
|
||||
if ($tm_player_id) {
|
||||
$matches_played = StatistikoPlayer::where('tm_player_id', (int) $tm_player_id)->pluck('match_id')->toArray();
|
||||
} else {
|
||||
$matches_played = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* STATTISTIC DATA
|
||||
*/
|
||||
switch ($filter['team_position']) {
|
||||
case 'home':
|
||||
$res = StatistikoEvent::where('league_id', $league_id)
|
||||
->where('home_id', '=', $team_id)
|
||||
->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})
|
||||
->get();
|
||||
break;
|
||||
$res = StatistikoEvent::where('league_id', $league_id)
|
||||
->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);
|
||||
}
|
||||
})
|
||||
->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})
|
||||
->orderBy('starttime')
|
||||
->get();
|
||||
|
||||
case 'away':
|
||||
$res = StatistikoEvent::where('league_id', $league_id)
|
||||
->where('away_id', '=', $team_id)
|
||||
->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})
|
||||
->get();
|
||||
break;
|
||||
// dd($res);
|
||||
|
||||
default:
|
||||
$res = StatistikoEvent::where('league_id', $league_id)
|
||||
->where(function ($query) use ($team_id) {
|
||||
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
})
|
||||
->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})->get();
|
||||
break;
|
||||
}
|
||||
$total = count($res);
|
||||
// Log::info($res);
|
||||
// Log::info($total);
|
||||
|
||||
$datasets = [];
|
||||
$labels = [];
|
||||
@@ -243,6 +199,8 @@ class EventsLoad
|
||||
'labels' => $labels,
|
||||
];
|
||||
|
||||
self::$last_query = $data;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
+42
-45
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Filament\Widgets\Data;
|
||||
|
||||
use App\Models\StatistikoPlayer;
|
||||
use App\Models\StatistikoEvent;
|
||||
|
||||
class PlayerLoad
|
||||
class LoadPlayer
|
||||
{
|
||||
public static $last_query = [];
|
||||
|
||||
@@ -12,6 +12,10 @@ class PlayerLoad
|
||||
{
|
||||
// dd($filter);
|
||||
|
||||
if (self::$last_query) {
|
||||
return self::$last_query;
|
||||
}
|
||||
|
||||
// "team_position" => "all"
|
||||
// "statistic_type" => "gls"
|
||||
// "similar_past_matches" => "none"
|
||||
@@ -37,6 +41,18 @@ class PlayerLoad
|
||||
|
||||
$tm_player_id = (int) $filter['tm_player_id'] ?? 0;
|
||||
|
||||
$team_position = $filter['team_position'];
|
||||
|
||||
$player_on_field = $filter['player_on_field'];
|
||||
|
||||
$statistic_type = $filter['statistic_type'] ?? 0;
|
||||
|
||||
$similar_past_matches = $filter['similar_past_matches'] ?? 0;
|
||||
|
||||
$start = $filter['start_date'] ?? 0;
|
||||
|
||||
$end = $filter['end_date'] ?? 0;
|
||||
|
||||
if (! $league_id) {
|
||||
return [];
|
||||
}
|
||||
@@ -47,49 +63,28 @@ class PlayerLoad
|
||||
return [];
|
||||
}
|
||||
|
||||
$team_position = $filter['team_position'];
|
||||
|
||||
$player_on_field = $filter['player_on_field'];
|
||||
|
||||
if (self::$last_query) {
|
||||
$res = self::$last_query;
|
||||
} else {
|
||||
|
||||
$res = StatistikoPlayer::with('event')->where('tm_player_id', $tm_player_id)
|
||||
->when($team_position, function ($query) use ($team_id, $team_position) {
|
||||
/**
|
||||
* TEAM HOME/AWAY
|
||||
*/
|
||||
switch ($team_position) {
|
||||
case 'home':
|
||||
return $query->where('activeteam_id', $team_id);
|
||||
break;
|
||||
|
||||
case 'away':
|
||||
return $query->where('activeteam_id', '!=', $team_id);
|
||||
break;
|
||||
}
|
||||
})->when($player_on_field, function ($query) use ($player_on_field) {
|
||||
/**
|
||||
* LINEUP
|
||||
*/
|
||||
switch ($player_on_field) {
|
||||
case 'lineup':
|
||||
return $query->where('lineup', 'T');
|
||||
break;
|
||||
case 'substituted':
|
||||
return $query->where('lineup', 'P');
|
||||
break;
|
||||
}
|
||||
|
||||
})->get();
|
||||
|
||||
self::$last_query = $res;
|
||||
}
|
||||
|
||||
$statistic_type = $filter['statistic_type'] ?? 0;
|
||||
|
||||
// $fields = 'goals,fouls,offsides,shots_on_target,shots_off_target, subtype_event_during_the_match';
|
||||
/**
|
||||
* STATTISTIC DATA
|
||||
*/
|
||||
$res = StatistikoEvent::where('league_id', $league_id)
|
||||
->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);
|
||||
}
|
||||
})
|
||||
->when($matches_played, function ($query) use ($matches_played) {
|
||||
return $query->whereIn('match_id', $matches_played);
|
||||
})->when($start, function ($query) use ($start) {
|
||||
return $query->where('starttime', '>=', $start);
|
||||
})->when($end, function ($query) use ($end) {
|
||||
return $query->where('starttime', '<=', $end);
|
||||
})->first();
|
||||
|
||||
$labels = [];
|
||||
$datasets = [];
|
||||
@@ -142,6 +137,8 @@ class PlayerLoad
|
||||
'labels' => $labels,
|
||||
];
|
||||
|
||||
self::$last_query = $data;
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user