From 2b85bf890c298ea787e893a16f4efbda3bae000d Mon Sep 17 00:00:00 2001 From: salam Date: Sun, 7 Jun 2026 07:42:20 +0200 Subject: [PATCH] wip ss --- app/Console/Commands/Grapper/Sofascore.php | 4 +-- .../Commands/Grapper/Sofascore/Tournament.php | 28 ++++++++++++------- app/Console/Commands/Nuh.php | 4 ++- .../Pages/ListSofaScoreTournaments.php | 2 +- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/app/Console/Commands/Grapper/Sofascore.php b/app/Console/Commands/Grapper/Sofascore.php index 8cce2c30..e88ec351 100644 --- a/app/Console/Commands/Grapper/Sofascore.php +++ b/app/Console/Commands/Grapper/Sofascore.php @@ -20,12 +20,12 @@ class Sofascore public static function switch() { $debug = Nuh::$options['d'] ?? 0; - $truncat = Nuh::$options['t'] ?? 0; - if ($truncat) { + if (Nuh::$options['truncate']) { SofaScoreDayTournament::truncate(); SofaScoreTournament::truncate(); SofaScoreCategorie::truncate(); + Notice::note('Table SofaScoreDayTournament, SofaScoreTournament, SofaScoreCategorie truncated', 'b', 1); } if ($debug) { diff --git a/app/Console/Commands/Grapper/Sofascore/Tournament.php b/app/Console/Commands/Grapper/Sofascore/Tournament.php index b97d8e5e..cc3f0750 100644 --- a/app/Console/Commands/Grapper/Sofascore/Tournament.php +++ b/app/Console/Commands/Grapper/Sofascore/Tournament.php @@ -25,37 +25,37 @@ class Tournament { $debug = Nuh::$options['d'] ?? 0; - $YEAR_GO_BACK = date('Y') - 5; - $sport_id = Nuh::$options['sport_id']; - $slug = Sport::where('id', $sport_id)->value('ss_slug'); + $sport = Sport::where('id', $sport_id)->first(); $dates = Carbon::now(); - while ($dates >= Carbon::now()->subYears($YEAR_GO_BACK)) { + while ($dates >= Carbon::now()->subYears($sport->ss_grap_years)) { $tournaments_counter = 0; $day = $dates->format('Y-m-d'); - Notice::note('sport: '.Nuh::$options['sport'].' day: '.$day, 'p'); - /** * grap only one time/sport check */ - if (! SofaScoreDay::where('day', $day)->where($slug, 1)->first()) { + if (! SofaScoreDay::where('day', $day)->where($sport->ss_slug, 1)->first()) { - SofaScoreDay::updateOrCreate(['day' => $day], [$slug => 1]); + if ($debug) { + Notice::note('Grapping Sport: '.Nuh::$options['sport'].' Day: '.$day, 'g'); + } + + SofaScoreDay::updateOrCreate(['day' => $day], [$sport->ss_slug => 1]); $page = 1; while ($page) { - $url = Nuh::$options['base_url']."api/v1/sport/$slug/scheduled-tournaments/$day/page/$page"; + $url = Nuh::$options['base_url']."api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page"; $rand = rand(1000000, 2000000); if ($debug) { - Notice::note("Sleep $rand msec", 'g'); + Notice::note("Sleep $rand msec", 'y'); } usleep($rand); @@ -152,6 +152,14 @@ class Tournament Notice::note("tournaments: $tournaments_counter", 'p'); } + + if (Nuh::$options['test']) { + Notice::note('Test exit after one day', 'b', 1); + } + } else { + if ($debug) { + Notice::note('Having Sport: '.Nuh::$options['sport'].' Day: '.$day, 'b'); + } } $dates->subDay(); } diff --git a/app/Console/Commands/Nuh.php b/app/Console/Commands/Nuh.php index de7c714a..3110a49b 100644 --- a/app/Console/Commands/Nuh.php +++ b/app/Console/Commands/Nuh.php @@ -23,7 +23,7 @@ class Nuh extends Command public static $id = 0; - protected $signature = 'nuh {process=help} {--id=0} {--fn=} {--gid=} {--p} {--d} {--x} {--t} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e}'; + protected $signature = 'nuh {process=help} {--truncate} {--test} {--id=0} {--fn=} {--gid=} {--p} {--d} {--x} {--t} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e}'; public function handle() { @@ -40,6 +40,8 @@ class Nuh extends Command $txt .= '--id=matchid (optional) calling spezific id'.PHP_EOL; $txt .= '--fn=name (optional) [bkms, markets]'.PHP_EOL; $txt .= '--gid=groupid (optional) [bkms, groupid]'.PHP_EOL; + $txt .= '--truncate (optional)'.PHP_EOL; + $txt .= '--test (optional)'.PHP_EOL; $txt .= '----------------------------------------------'.PHP_EOL.PHP_EOL; $txt .= 'Options'.PHP_EOL; $txt .= '----------------------------------------------'.PHP_EOL; diff --git a/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Pages/ListSofaScoreTournaments.php b/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Pages/ListSofaScoreTournaments.php index 17f952d2..38ff93c1 100644 --- a/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Pages/ListSofaScoreTournaments.php +++ b/app/Filament/Clusters/StaticData/Resources/SofaScoreTournaments/Pages/ListSofaScoreTournaments.php @@ -13,7 +13,7 @@ class ListSofaScoreTournaments extends ListRecords protected function getHeaderActions(): array { return [ - CreateAction::make(), + // CreateAction::make(), ]; } }