This commit is contained in:
salam committed 2026-10-05 19:39:34 +02:00
1 parent 74ff567cce
commit 916fb91895
9 files changed
+393 -236

No files matched your search

+3
View File
@@ -521,6 +521,9 @@ class Statistic extends BaseDashboard
]); ]);
} }
/**
* Summary of generateDynamicPayload
*/
public function generateDynamicPayload(): string public function generateDynamicPayload(): string
{ {
$data = LoadEventsBoxes::load($this->filters, false); $data = LoadEventsBoxes::load($this->filters, false);
@@ -6,6 +6,7 @@ use App\Filament\Widgets\Boxes\Helper\ExpectationCalculation;
use App\Filament\Widgets\Boxes\Helper\ExpectationCollecting; use App\Filament\Widgets\Boxes\Helper\ExpectationCollecting;
use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryAll; use App\Filament\Widgets\Charts\LoadEvents\LoadEventsQueryAll;
use App\Utilities\Round; use App\Utilities\Round;
use Illuminate\Support\Facades\Log;
class ExpectationsTeam class ExpectationsTeam
{ {
@@ -29,20 +30,24 @@ class ExpectationsTeam
} }
$res = LoadEventsQueryAll::load($filter, $match); $res = LoadEventsQueryAll::load($filter, $match);
$count_events = $res->count(); $count_events = $res->count();
if (! $res) { if (! $res) {
return []; return [];
} }
$tmp = []; $tmp = [];
foreach ($res as $value) { foreach ($res as $value) {
ExpectationCollecting::sort($tmp, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match); ExpectationCollecting::sort($similar_past_matches, $tmp, 'gls', $value->home_id, $value->away_id, $value->gls_h, $value->gls_a, $match);
ExpectationCollecting::sort($tmp, 'fls', $value->home_id, $value->away_id, $value->fls_h, $value->fls_a, $match); ExpectationCollecting::sort($similar_past_matches, $tmp, 'fls', $value->home_id, $value->away_id, $value->fls_h, $value->fls_a, $match);
ExpectationCollecting::sort($tmp, 'ofs', $value->home_id, $value->away_id, $value->ofs_h, $value->ofs_a, $match); ExpectationCollecting::sort($similar_past_matches, $tmp, 'ofs', $value->home_id, $value->away_id, $value->ofs_h, $value->ofs_a, $match);
ExpectationCollecting::sort($tmp, 'crd', $value->home_id, $value->away_id, $value->crd_h, $value->crd_a, $match); ExpectationCollecting::sort($similar_past_matches, $tmp, 'crd', $value->home_id, $value->away_id, $value->crd_h, $value->crd_a, $match);
ExpectationCollecting::sort($tmp, 'snt', $value->home_id, $value->away_id, $value->snt_h, $value->snt_a, $match); ExpectationCollecting::sort($similar_past_matches, $tmp, 'snt', $value->home_id, $value->away_id, $value->snt_h, $value->snt_a, $match);
ExpectationCollecting::sort($tmp, 'tsh', $value->home_id, $value->away_id, $value->tsh_h, $value->tsh_a, $match); ExpectationCollecting::sort($similar_past_matches, $tmp, 'tsh', $value->home_id, $value->away_id, $value->tsh_h, $value->tsh_a, $match);
ExpectationCollecting::sort($tmp, 'crn', $value->home_id, $value->away_id, $value->crn_h, $value->crn_a, $match); ExpectationCollecting::sort($similar_past_matches, $tmp, 'crn', $value->home_id, $value->away_id, $value->crn_h, $value->crn_a, $match);
} }
// Log::debug('expectations '.$count_events, $tmp);
$expectations = ExpectationCalculation::calc($tmp); $expectations = ExpectationCalculation::calc($tmp);
$expectations['gls']['name'] = 'Goals'; $expectations['gls']['name'] = 'Goals';
$expectations['fls']['name'] = 'Fouls'; $expectations['fls']['name'] = 'Fouls';
@@ -53,6 +58,8 @@ class ExpectationsTeam
$expectations['home'] = $home_team; $expectations['home'] = $home_team;
$expectations['away'] = $away_team; $expectations['away'] = $away_team;
// Log::debug('expectations '.$count_events, $expectations);
$expectations += ['win_count' => 0, 'draw_count' => 0, 'lost_count' => 0]; $expectations += ['win_count' => 0, 'draw_count' => 0, 'lost_count' => 0];
foreach ($res as $value) { foreach ($res as $value) {
if ($team_id && $team_position == 'home') { if ($team_id && $team_position == 'home') {
@@ -4,9 +4,12 @@ namespace App\Filament\Widgets\Boxes\Helper;
class ExpectationCollecting class ExpectationCollecting
{ {
public static function sort(array &$result, string $type, int $home_id, int $away_id, float $val_home, float $val_away, object $match) public static function sort(string $similar_past_matches, array &$result, string $type, int $home_id, int $away_id, float $val_home, float $val_away, object $match)
{ {
if ($similar_past_matches != 'none') {
$result[$type.'_home_made_total'][] = $val_home;
$result[$type.'_away_made_total'][] = $val_away;
} else {
if ($home_id == $match->home_id) { if ($home_id == $match->home_id) {
$result[$type.'_home_made_total'][] = $val_home; $result[$type.'_home_made_total'][] = $val_home;
$result[$type.'_home_made_home'][] = $val_home; $result[$type.'_home_made_home'][] = $val_home;
@@ -44,3 +47,4 @@ class ExpectationCollecting
} }
} }
} }
}
+3
View File
@@ -15,6 +15,7 @@ class BoxesBettypeAll extends StatsOverviewWidget
{ {
use InteractsWithPageFilters; use InteractsWithPageFilters;
// Within your Widget class:
protected ?string $pollingInterval = null; protected ?string $pollingInterval = null;
protected int|array|null $columns = null; protected int|array|null $columns = null;
@@ -33,6 +34,8 @@ class BoxesBettypeAll extends StatsOverviewWidget
{ {
$data = LoadEventsBoxes::load($this->filters, false); $data = LoadEventsBoxes::load($this->filters, false);
// dd($data);
$similar_past_matches = $this->filters['similar_past_matches']; $similar_past_matches = $this->filters['similar_past_matches'];
$team_position = $this->filters['team_position']; $team_position = $this->filters['team_position'];
@@ -6,7 +6,6 @@ use App\Filament\Pages\Selections\Helper\GetSeason;
use App\Models\SofaScoreRosa; use App\Models\SofaScoreRosa;
use App\Models\StatistikoEvent; use App\Models\StatistikoEvent;
use App\Models\StatistikoPlayer; use App\Models\StatistikoPlayer;
use Illuminate\Support\Facades\Log;
class LoadEventsQuery class LoadEventsQuery
{ {
@@ -137,10 +136,6 @@ class LoadEventsQuery
->orderBy('starttime', 'ASC') ->orderBy('starttime', 'ASC')
->get(); ->get();
// dd($res);
// dd($season, $league_id, $res);
Log::info('season', $season);
$arr = []; $arr = [];
foreach ($res as $value) { foreach ($res as $value) {
@@ -33,6 +33,7 @@ class LoadEventsQueryAll
$total_range = []; $total_range = [];
if ($similar_past_matches != 'none') { if ($similar_past_matches != 'none') {
$team_id = 0; $team_id = 0;
$ss_player_id = 0;
$team_position = ''; $team_position = '';
$exp_handicap = $match->exp_away - $match->exp_home; $exp_handicap = $match->exp_away - $match->exp_home;
$exp_total = $match->exp_away + $match->exp_home; $exp_total = $match->exp_away + $match->exp_home;
@@ -40,12 +41,6 @@ class LoadEventsQueryAll
$total_range = [$exp_total - $accuracy, $exp_total + $accuracy]; $total_range = [$exp_total - $accuracy, $exp_total + $accuracy];
} }
if ($similar_past_matches != 'none') {
$team_position = '';
$team_id = 0;
$ss_player_id = 0;
}
// dd($season); // dd($season);
$season = GetSeason::load($season, $seasonmode); $season = GetSeason::load($season, $seasonmode);
@@ -98,6 +93,8 @@ class LoadEventsQueryAll
/** /**
* STATTISTIC DATA * STATTISTIC DATA
*/ */
// Log::debug('result', [$similar_past_matches, $home_id, $away_id, $team_id]);
return StatistikoEvent::with('home')->with('away') return StatistikoEvent::with('home')->with('away')
->where(function ($query) use ($league_id, $similar_past_matches) { ->where(function ($query) use ($league_id, $similar_past_matches) {
switch ($similar_past_matches) { switch ($similar_past_matches) {
@@ -0,0 +1,141 @@
<?php
namespace App\Filament\Widgets\Charts\LoadEvents;
use App\Filament\Pages\Selections\Helper\GetSeason;
use App\Models\StatistikoEvent;
use App\Models\StatistikoPlayer;
class LoadEventsQuerySPM
{
public static function load(array $filter, object $match)
{
$league_id = (int) $filter['league_id'] ?? 0;
$team_id = (int) $filter['team_id'] ?? 0;
$season = $filter['season'];
$seasonmode = $filter['seasonmode'];
$season_or_date = $filter['season_or_date'];
$accuracy = (float) $filter['accuracy'] ?? 0.5;
$start = $filter['start_date'] ?? 0;
$end = $filter['end_date'] ?? 0;
if ($season_or_date == 'season') {
$start = 0;
$end = 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'];
$team_position = $filter['team_position'];
$home_id = $match->home_id;
$away_id = $match->away_id;
$handicap_range = [];
$total_range = [];
if ($similar_past_matches != 'none') {
$team_id = 0;
$ss_player_id = 0;
$team_position = '';
$exp_handicap = $match->exp_away - $match->exp_home;
$exp_total = $match->exp_away + $match->exp_home;
$handicap_range = [$exp_handicap - $accuracy, $exp_handicap + $accuracy];
$total_range = [$exp_total - $accuracy, $exp_total + $accuracy];
}
// dd($season);
$season = GetSeason::load($season, $seasonmode);
/**
* IF WITH PLAYER
*/
$matches_played = [];
if ($ss_player_id) {
$matches_season = StatistikoEvent::whereIn('season', $season)
->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;
}
}
// dd($handicap_range, $total_range);
/**
* STATTISTIC DATA
*/
// Log::debug('result', [$similar_past_matches, $home_id, $away_id, $team_id]);
return StatistikoEvent::with('home')->with('away')
->where(function ($query) use ($league_id, $similar_past_matches) {
switch ($similar_past_matches) {
case 'none':
case 'league':
return $query->where('league_id', $league_id);
}
})
->where(function ($query) use ($team_id, $home_id, $away_id, $similar_past_matches) {
if ($similar_past_matches == 'none') {
if ($team_id) {
return $query->orWhere('home_id', $team_id)
->orWhere('away_id', '=', $team_id);
} else {
return $query->whereIn('home_id', [$home_id, $away_id])->orWhereIn('away_id', [$home_id, $away_id]);
}
}
})
->when($matches_played, function ($query) use ($matches_played, $player_on_field) {
if ($player_on_field == 'notplayed') {
return $query->whereNotIn('match_id', $matches_played);
} else {
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->whereDate('starttime', '>=', $start);
})->when($end, function ($query) use ($end) {
return $query->whereDate('starttime', '<=', $end);
})
->when($season, function ($query) use ($season, $season_or_date, $similar_past_matches) {
if ($similar_past_matches == 'none' && $season_or_date == 'season') {
return $query->whereIn('season', $season);
}
})
->orderBy('starttime', 'ASC')
->get();
}
}
+5 -5
View File
@@ -31,7 +31,7 @@ class CloudflareSolverService
]); ]);
if ($response->failed()) { if ($response->failed()) {
Log::error('FlareSolverr Verbindungsfehler. Status: ' . $response->status()); // Log::error('FlareSolverr Verbindungsfehler. Status: ' . $response->status());
return null; return null;
} }
@@ -56,15 +56,15 @@ class CloudflareSolverService
return $decoded; return $decoded;
} }
Log::error('Extrahiertes Textfragment ist kein gültiges JSON.'); // Log::error('Extrahiertes Textfragment ist kein gültiges JSON.');
} else { } else {
Log::error('Kein JSON-Muster { ... } im HTML gefunden.'); // Log::error('Kein JSON-Muster { ... } im HTML gefunden.');
} }
} else { } else {
Log::error('FlareSolverr konnte die Seite nicht umgehen: ' . json_encode($data)); // Log::error('FlareSolverr konnte die Seite nicht umgehen: '.json_encode($data));
} }
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error('PHP Exception im CloudflareSolverService: ' . $e->getMessage()); // Log::error('PHP Exception im CloudflareSolverService: '.$e->getMessage());
} }
Notice::note('ERROR connecting FLARESOLVERR_IP_DOCKER', 'br', 1); Notice::note('ERROR connecting FLARESOLVERR_IP_DOCKER', 'br', 1);
Generated
+218 -211
View File
File diff suppressed because it is too large. Load diff