From 33e8107517982f4d44e15d93099a2e52307bc696 Mon Sep 17 00:00:00 2001 From: salam Date: Fri, 16 Oct 2026 16:00:36 +0200 Subject: [PATCH] add ss_liga_code to torunaments --- .../Tables/SofaScoreTournamentsTable.php | 10 ++++++- app/Models/SofaScoreTournament.php | 1 + app/Traits/Sofascore/GrappingSofascore.php | 26 ++++++++++++++----- app/Traits/Sofascore/GrappingTeams.php | 22 +++++++++++----- app/Traits/Sofascore/GrappingToExcel.php | 7 +++-- ...13_create_sofa_score_tournaments_table.php | 1 + 6 files changed, 49 insertions(+), 18 deletions(-) diff --git a/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php b/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php index df4f9882..59d149b4 100644 --- a/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php +++ b/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Tables/SofaScoreTournamentsTable.php @@ -6,6 +6,7 @@ use Filament\Forms\Components\Toggle; use Filament\Support\Enums\IconSize; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; +use Filament\Tables\Columns\TextInputColumn; use Filament\Tables\Columns\ToggleColumn; use Filament\Tables\Enums\FiltersLayout; use Filament\Tables\Filters\Filter; @@ -35,9 +36,16 @@ class SofaScoreTournamentsTable ->searchable(), TextColumn::make('sofascore_category.name') ->label('Country') + ->searchable() ->icon(fn ($record) => $record->sofascore_category->flag) ->sortable(), - TextColumn::make('name')->searchable()->sortable(), + TextInputColumn::make('ss_liga_code') + ->label('SofaScore Liga Code') + ->searchable() + ->sortable(), + TextColumn::make('name') + ->searchable() + ->sortable(), // ToggleColumn::make('major') // ->tooltip('Grapping Rose') // ->alignCenter() diff --git a/app/Models/SofaScoreTournament.php b/app/Models/SofaScoreTournament.php index cc287bcd..28724450 100644 --- a/app/Models/SofaScoreTournament.php +++ b/app/Models/SofaScoreTournament.php @@ -15,6 +15,7 @@ class SofaScoreTournament extends Model 'id', 'sport_id', 'tournament_id', + 'ss_liga_code', 'sofa_score_category_id', 'name', 'slug', diff --git a/app/Traits/Sofascore/GrappingSofascore.php b/app/Traits/Sofascore/GrappingSofascore.php index 01325f6c..aaeca454 100644 --- a/app/Traits/Sofascore/GrappingSofascore.php +++ b/app/Traits/Sofascore/GrappingSofascore.php @@ -139,6 +139,8 @@ trait GrappingSofascore $this->speed = $this->ask_speed(); + $this->debug = $this->ask_debug(); + $daily_way = $this->select_daily_days(); if ($this->ask_settings_download() == 'yes') { @@ -312,16 +314,16 @@ trait GrappingSofascore label: 'What task should run?', scroll: 10, options: [ - 'daily' => 'Daily run', - 'back' => 'Select day back', + 'daily' => 'Daily', + 'back' => 'Day back', 'range' => 'Range', - 'rose' => 'Rose Teams', + 'rose' => 'Rose', 'player' => 'Player', 'settings' => 'Settings', 'excel' => 'Excel', - 'mail' => 'Send Mail', - 'clear' => 'Empty Folder', - 'delete_orphants' => 'Delete Imported Orphants', + 'mail' => 'Mail', + 'clear' => 'Clear Folder', + 'delete_orphants' => 'Delete Imported', ] ); } @@ -395,6 +397,18 @@ trait GrappingSofascore ); } + protected function ask_debug(): int + { + return select( + label: 'Show debubing?', + default: 1, + options: [ + 0 => 'No', + 1 => 'Yes', + ] + ); + } + protected function select_what_delete(): string { return select( diff --git a/app/Traits/Sofascore/GrappingTeams.php b/app/Traits/Sofascore/GrappingTeams.php index 8e369bac..0f8d35ba 100644 --- a/app/Traits/Sofascore/GrappingTeams.php +++ b/app/Traits/Sofascore/GrappingTeams.php @@ -29,14 +29,21 @@ trait GrappingTeams $this->speed = $this->ask_speed(); - $what = $this->select_what_to_grap(); + switch ($this->ask_restart()) { + case 'clear': + SofaScoreRosa::query()->update(['grapped' => 0]); + File::cleanDirectory($this->data_dir); + break; + case 'restart': + SofaScoreRosa::query()->update(['grapped' => 0]); + break; - if ($this->restart) { - SofaScoreRosa::query()->update(['grapped' => 0]); - File::cleanDirectory($this->data_dir); + default: + // code... + break; } - switch ($what) { + switch ($title = $this->select_what_to_grap()) { case 'major': $tournaments = SofaScoreTournament::where('enabled', 1)->whereIn('tournament_id', $major)->pluck('tournament_id')->toArray(); break; @@ -45,6 +52,7 @@ trait GrappingTeams break; default: $tmp = self::load_tornament_ids(); + $title = 'rose_'.str_replace(',', '_', $tmp); $tournaments = explode(',', $tmp); break; } @@ -61,7 +69,7 @@ trait GrappingTeams if ($this->debug) { $key++; - echo "\n$key/$count\n"; + Notice::note($key / $count.' - '.$value->ss_team_name); } $url = $this->base_url."api/v1/team/$value->ss_team_id/players"; @@ -87,7 +95,7 @@ trait GrappingTeams $this->grapper_sleep($this->speed); } - $this->import_to_excel("rose_$what"); + $this->import_to_excel('rose', $title); if ($this->debug) { Notice::note('DONE', 'bb'); diff --git a/app/Traits/Sofascore/GrappingToExcel.php b/app/Traits/Sofascore/GrappingToExcel.php index 71fb5aff..bc556fa5 100644 --- a/app/Traits/Sofascore/GrappingToExcel.php +++ b/app/Traits/Sofascore/GrappingToExcel.php @@ -15,7 +15,7 @@ trait GrappingToExcel protected string $titel = ''; - public function import_to_excel(string $folder) + public function import_to_excel(string $folder, $title = '') { ini_set('memory_limit', -1); @@ -39,11 +39,10 @@ trait GrappingToExcel $this->make_file($this->data_dir); break; - case 'rose_major': - case 'rose_others': + case 'rose': $day = Carbon::now()->subDay()->format('Y-m-d'); - $this->titel = ucfirst($folder).'-'.$day; + $this->titel = ucfirst($title).'-'.$day; $this->make_file($this->data_dir); break; } diff --git a/database/migrations/2026_06_06_134913_create_sofa_score_tournaments_table.php b/database/migrations/2026_06_06_134913_create_sofa_score_tournaments_table.php index 1c752c20..0450bd4e 100644 --- a/database/migrations/2026_06_06_134913_create_sofa_score_tournaments_table.php +++ b/database/migrations/2026_06_06_134913_create_sofa_score_tournaments_table.php @@ -18,6 +18,7 @@ return new class extends Migration $table->integer('sofa_score_category_id')->index(); $table->string('slug')->index(); $table->string('name'); + $table->string('ss_liga_code'); $table->boolean('major')->index()->default(0); $table->boolean('enabled')->index()->default(0); $table->boolean('disabled')->index()->default(0);