test export player wip
This commit is contained in:
1 parent
b2239596ec
commit
19169d38f3
2 files changed
+10
-94
No files matched your search
+1
-93
@@ -13,7 +13,6 @@ 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
|
||||
{
|
||||
@@ -22,99 +21,8 @@ class ListStatistikoPlayers extends ListRecords
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('clean_download')
|
||||
->label('Direkt Download')
|
||||
->icon('heroicon-o-arrow-down-tray')
|
||||
->action(function (): StreamedResponse {
|
||||
set_time_limit(0);
|
||||
|
||||
return response()->streamDownload(function () {
|
||||
// 1. Output-Stream öffnen
|
||||
$output = fopen('php://output', 'w');
|
||||
|
||||
// 2. CSV-Header schreiben
|
||||
fputcsv($output, ['ID', 'Nachricht', 'Level', 'Erstellt am']);
|
||||
|
||||
// 3. MongoDB Cursor nutzen (Lädt immer nur 1 Dokument gleichzeitig in den RAM)
|
||||
StatistikoPlayer::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 ?? '',
|
||||
]);
|
||||
});
|
||||
|
||||
// 4. Stream schließen
|
||||
fclose($output);
|
||||
}, 'player-history_all_'.now()->format('Y-m-d_H-i-s').'.csv');
|
||||
}),
|
||||
ExportAction::make('download_players')
|
||||
->label('Export Download')
|
||||
->label('Export')
|
||||
->icon('phosphor-download')
|
||||
->columnMapping(false)
|
||||
->chunkSize(250)
|
||||
|
||||
Reference in new issue
Block a user