wip
This commit is contained in:
1 parent
4ca4a32ca1
commit
ee3afc95da
1 file changed
+105
+105
@@ -13,6 +13,7 @@ use Filament\Actions\Exports\Models\Export;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class ListStatistikoPlayers extends ListRecords
|
||||
{
|
||||
@@ -21,6 +22,110 @@ class ListStatistikoPlayers extends ListRecords
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('stream_export')
|
||||
->label('Direkt Download')
|
||||
->icon('heroicon-o-arrow-down-tray')
|
||||
->color('success')
|
||||
->action(function (): StreamedResponse {
|
||||
// Zeit- und Speicherlimits für diesen HTTP-Request aufheben
|
||||
set_time_limit(0);
|
||||
ini_set('memory_limit', '512M');
|
||||
|
||||
return response()->streamDownload(function () {
|
||||
$output = fopen('php://output', 'w');
|
||||
|
||||
// UTF-8 BOM für Excel (Umlaute-Fix)
|
||||
fprintf($output, chr(0xEF).chr(0xBB).chr(0xBF));
|
||||
|
||||
// 2. Abfrage definieren
|
||||
$query = StatistikoPlayer::query()->orderBy('_id', 'asc');
|
||||
|
||||
// FALLS SIE NUR AB ZEILE 200.000 STARTEN WOLLEN:
|
||||
// Nutzen Sie kein ->skip(). Wenn Sie die letzte MongoDB-_id aus
|
||||
// Ihrem vorherigen erfolgreichen Export kennen (z.B. '654321...'),
|
||||
// filtern Sie stattdessen performant so:
|
||||
// $query->where('_id', '>', 'HIER_DIE_LETZTE_ERFOLGREICHE_ID_EINTRAGEN');
|
||||
|
||||
// 3. Daten ohne Chunk-Einschränkung direkt aus MongoDB streamen
|
||||
$query->getQuery()
|
||||
->options(['noCursorTimeout' => true])
|
||||
->cursor()
|
||||
->each(function ($row) use ($output) {
|
||||
fputcsv($output, [
|
||||
$row->match_id ?? '',
|
||||
$row->ss_player_id ?? '',
|
||||
$row->tm_player_id ?? '',
|
||||
$row->sport_id ?? '',
|
||||
$row->activeteam_id ?? '',
|
||||
$row->assists ?? '',
|
||||
$row->bcc ?? '',
|
||||
$row->bcm ?? '',
|
||||
$row->blocked_shots ?? '',
|
||||
$row->card_red ?? '',
|
||||
$row->card_yellow ?? '',
|
||||
$row->card_yellowred ?? '',
|
||||
$row->clearance_off_line ?? '',
|
||||
$row->clearances ?? '',
|
||||
$row->cross_done ?? '',
|
||||
$row->description_event_during_the_match ?? '',
|
||||
$row->dispossessed ?? '',
|
||||
$row->dribbled_past ?? '',
|
||||
$row->dribbles_won ?? '',
|
||||
$row->errors_lead_to_a_goal ?? '',
|
||||
$row->errors_lead_to_a_shot ?? '',
|
||||
$row->fouls ?? '',
|
||||
$row->goals ?? '',
|
||||
$row->good_high_claim ?? '',
|
||||
$row->hit_woodwork ?? '',
|
||||
$row->ingamepenalty_missed ?? '',
|
||||
$row->interceptions ?? '',
|
||||
$row->key_pass ?? '',
|
||||
$row->last_man_tackle ?? '',
|
||||
$row->lineup ?? '',
|
||||
$row->long_balls ?? '',
|
||||
$row->minute_event_during_the_match ?? '',
|
||||
$row->minutes_played ?? '',
|
||||
$row->offsides ?? '',
|
||||
$row->own_goals ?? '',
|
||||
$row->pass ?? '',
|
||||
$row->penalty_committed ?? '',
|
||||
$row->penalty_miss ?? '',
|
||||
$row->penalty_save ?? '',
|
||||
$row->penalty_won ?? '',
|
||||
$row->penaltyshoutout_missed ?? '',
|
||||
$row->penaltyshoutout_scored ?? '',
|
||||
$row->player_position ?? '',
|
||||
$row->playerrating_value ?? '',
|
||||
$row->playersubstitute_id ?? '',
|
||||
$row->possessions_lost ?? '',
|
||||
$row->punches ?? '',
|
||||
$row->runs_out ?? '',
|
||||
$row->saves ?? '',
|
||||
$row->saves_from_in_box ?? '',
|
||||
$row->shots_blocked ?? '',
|
||||
$row->shots_off_target ?? '',
|
||||
$row->shots_on_target ?? '',
|
||||
$row->subtype_event_during_the_match ?? '',
|
||||
$row->total_aerial_duels ?? '',
|
||||
$row->total_cross ?? '',
|
||||
$row->total_dribbles ?? '',
|
||||
$row->total_duels_aerial_won ?? '',
|
||||
$row->total_ground_duels ?? '',
|
||||
$row->total_ground_duels_won ?? '',
|
||||
$row->total_long_balls ?? '',
|
||||
$row->total_pass ?? '',
|
||||
$row->total_runs_out ?? '',
|
||||
$row->total_tackles ?? '',
|
||||
$row->touches ?? '',
|
||||
$row->type_event_during_the_match ?? '',
|
||||
$row->updated_at ?? '',
|
||||
$row->was_fouled ?? '',
|
||||
]);
|
||||
});
|
||||
|
||||
fclose($output);
|
||||
}, 'player_history_clean_'.now()->format('Y-m-d').'.csv');
|
||||
}),
|
||||
ExportAction::make('download_players')
|
||||
->label('Export')
|
||||
->icon('phosphor-download')
|
||||
|
||||
Reference in new issue
Block a user