From 4e460fba49c9267df9269f06a2b279ea30bb79a2 Mon Sep 17 00:00:00 2001 From: salam Date: Sat, 19 Sep 2026 19:28:42 +0200 Subject: [PATCH] wip --- app/Console/Commands/Grap.php | 48 +++++++++++-------- .../Commands/Grapper/Sofascore/Grapper.php | 13 ++++- .../Grapper/Sofascore/Helper/ClearDir.php | 23 +++++++++ .../Grapper/Sofascore/Helper/LoadDays.php | 23 +++++---- app/Filament/Widgets/PlayerProps/BoxNames.php | 2 +- app/Filament/Widgets/PlayerPropsDrop.php | 13 +++-- 6 files changed, 84 insertions(+), 38 deletions(-) create mode 100644 app/Console/Commands/Grapper/Sofascore/Helper/ClearDir.php diff --git a/app/Console/Commands/Grap.php b/app/Console/Commands/Grap.php index b727c78b..3dba584a 100644 --- a/app/Console/Commands/Grap.php +++ b/app/Console/Commands/Grap.php @@ -4,6 +4,7 @@ namespace App\Console\Commands; use App\Console\Commands\Grapper\Sofascore\Grapper; use App\Console\Commands\Grapper\Sofascore\GrapperTest; +use App\Console\Commands\Grapper\Sofascore\Helper\ClearDir; use App\Console\Commands\Grapper\Sofascore\Helper\SetStorage; use App\Console\Commands\Grapper\Sofascore\MakeExcel; use App\Console\Commands\Grapper\Sofascore\Rose; @@ -37,28 +38,28 @@ class Grap extends Command self::$options['base_url'] = 'https://www.sofascore.com/'; if (! self::$options['id']) { - $txt = 'PARAMETERS'.PHP_EOL; - $txt .= '--d debug'.PHP_EOL; - $txt .= '--r restart range'.PHP_EOL; - $txt .= '--f force'.PHP_EOL; - $txt .= '--m mail only'.PHP_EOL; - $txt .= '--R read file'.PHP_EOL; - $txt .= '--S save to file'.PHP_EOL; - $txt .= '--folder'.PHP_EOL; - $txt .= '-----------------------------------------------------------'.PHP_EOL; - $txt .= 'FUNCTION'.PHP_EOL; - $txt .= ' 1 grapper DAILY & subDays ( default 3)'.PHP_EOL; - $txt .= ' 2 grapper DATE'.PHP_EOL; - $txt .= ' 3 grapper RANGE'.PHP_EOL; - $txt .= ' 4 grapper ROSE'.PHP_EOL; - $txt .= ' 5 import to excel from folder'.PHP_EOL; - $txt .= ' 7 settings to local'.PHP_EOL; - $txt .= ' 11 move SQL'.PHP_EOL; - $txt .= ' 12 testing url for grapping'.PHP_EOL; + $txt = 'PARAMETERS' . PHP_EOL; + $txt .= '--d debug' . PHP_EOL; + $txt .= '--r restart range' . PHP_EOL; + $txt .= '--f force' . PHP_EOL; + $txt .= '--m mail only' . PHP_EOL; + $txt .= '--R read file' . PHP_EOL; + $txt .= '--S save to file' . PHP_EOL; + $txt .= '--folder' . PHP_EOL; + $txt .= '-----------------------------------------------------------' . PHP_EOL; + $txt .= 'FUNCTION' . PHP_EOL; + $txt .= ' 1 grapper DAILY & subDays ( default 3)' . PHP_EOL; + $txt .= ' 2 grapper LAST 3 DAYS' . PHP_EOL; + $txt .= ' 3 grapper RANGE' . PHP_EOL; + $txt .= ' 4 grapper ROSE' . PHP_EOL; + $txt .= ' 5 import to excel from folder' . PHP_EOL; + $txt .= ' 7 settings to local' . PHP_EOL; + $txt .= ' 11 move SQL' . PHP_EOL; + $txt .= ' 12 testing url for grapping' . PHP_EOL; Notice::note($txt, 'b', 1); } - Notice::note('Task Id '.self::$options['id'], 'gb'); + Notice::note('Task Id ' . self::$options['id'], 'gb'); switch (self::$options['id']) { @@ -77,10 +78,17 @@ class Grap extends Command break; case 2: - // DATE + // LAST 3 DAYS SetStorage::set(2); + ClearDir::clear(); + Grapper::load(2); + + MakeExcel::create(); + + SendMail::run(1); + break; case 3: // RANGE diff --git a/app/Console/Commands/Grapper/Sofascore/Grapper.php b/app/Console/Commands/Grapper/Sofascore/Grapper.php index d72e1ae7..ca09e343 100644 --- a/app/Console/Commands/Grapper/Sofascore/Grapper.php +++ b/app/Console/Commands/Grapper/Sofascore/Grapper.php @@ -34,7 +34,18 @@ class Grapper $count = 0; - $active_tournaments = SofaScoreTaskTournament::with('tournament')->where('sofa_score_task_id', $task_id)->where('disabled', false)->get(); + /** take for task 2 the same like for task 1 */ + switch ($task_id) { + case 1: + case 2: + $active_tournaments = SofaScoreTaskTournament::with('tournament')->where('sofa_score_task_id', 1)->where('disabled', false)->get(); + break; + + default: + $active_tournaments = SofaScoreTaskTournament::with('tournament')->where('sofa_score_task_id', $task_id)->where('disabled', false)->get(); + break; + } + /** * daily restart always diff --git a/app/Console/Commands/Grapper/Sofascore/Helper/ClearDir.php b/app/Console/Commands/Grapper/Sofascore/Helper/ClearDir.php new file mode 100644 index 00000000..f2259d14 --- /dev/null +++ b/app/Console/Commands/Grapper/Sofascore/Helper/ClearDir.php @@ -0,0 +1,23 @@ +cleanDirectory(Grap::$storage); + + if ($debug) { + Notice::note('Directory: ' . Grap::$storage . ' - All content cleard', 'p'); + } + } +} diff --git a/app/Console/Commands/Grapper/Sofascore/Helper/LoadDays.php b/app/Console/Commands/Grapper/Sofascore/Helper/LoadDays.php index 886b16e0..4416d077 100644 --- a/app/Console/Commands/Grapper/Sofascore/Helper/LoadDays.php +++ b/app/Console/Commands/Grapper/Sofascore/Helper/LoadDays.php @@ -14,7 +14,6 @@ class LoadDays { $debug = Grap::$options['d'] ?? 0; $restart = Grap::$options['r'] ?? 0; - $date = Grap::$options['date'] ?? ''; $dates = []; @@ -24,6 +23,7 @@ class LoadDays return []; } + $task = SofaScoreTask::with('sport')->where('id', $task_id)->first(); if ($debug) { @@ -36,16 +36,21 @@ class LoadDays $dates[] = ValidateDate::get(Grap::$folder); break; - case 'date': - $dates[] = ValidateDate::get($date); - break; - + case 'last3days': case 'range': - $from = ValidateDate::get($task->day_from); - $to = ValidateDate::get($task->day_to); + switch ($task_id) { + case 2: + $from = Carbon::now()->subDays(3); + $to = Carbon::now()->subDays(1); + break; - $from = Carbon::createFromDate($from); - $to = Carbon::createFromDate($to); + default: + $from = ValidateDate::get($task->day_from); + $to = ValidateDate::get($task->day_to); + $from = Carbon::createFromDate($from); + $to = Carbon::createFromDate($to); + break; + } $lengthdates = $from->diffInDays($to); diff --git a/app/Filament/Widgets/PlayerProps/BoxNames.php b/app/Filament/Widgets/PlayerProps/BoxNames.php index f1abf9f5..e281f631 100644 --- a/app/Filament/Widgets/PlayerProps/BoxNames.php +++ b/app/Filament/Widgets/PlayerProps/BoxNames.php @@ -19,7 +19,7 @@ class BoxNames 17 => 'DM', 18 => 'MC', 19 => 'AM', - 20 => 'SM', + 20 => 'SS', 21 => 'ST', 23 => 'DC', 24 => 'DM', diff --git a/app/Filament/Widgets/PlayerPropsDrop.php b/app/Filament/Widgets/PlayerPropsDrop.php index 0e23ff61..ce0f310a 100644 --- a/app/Filament/Widgets/PlayerPropsDrop.php +++ b/app/Filament/Widgets/PlayerPropsDrop.php @@ -621,44 +621,43 @@ class PlayerPropsDrop extends Widget $final = number_format($result['asp_player_goals'], 3); $results[$key]['finale_tamx_gls'] = $tamx; $results[$key]['finale_calc_gls'] = $final; - $this->players[$k]['gls'] = $final > $tamx ? $final : $tamx; + $this->players[$k]['gls'] = (float) $final > (float) $tamx ? $final : $tamx; $tamx = number_format($map[$pos]['crd'], 3); $final = number_format($result['asp_player_cards'], 3); $results[$key]['finale_tamx_crd'] = $tamx; $results[$key]['finale_calc_crd'] = $final; - $this->players[$k]['crd'] = $final > $tamx ? $final : $tamx; + $this->players[$k]['crd'] = (float) $final > (float) $tamx ? $final : $tamx; $tamx = number_format($map[$pos]['fls'], 3); $final = number_format($result['asp_player_fouls'], 3); $results[$key]['finale_tamx_fls'] = $tamx; $results[$key]['finale_calc_fls'] = $final; - $this->players[$k]['fls'] = $final > $tamx ? $final : $tamx; + $this->players[$k]['fls'] = (float) $final > (float) $tamx ? $final : $tamx; $tamx = number_format($map[$pos]['ofs'], 3); $final = number_format($result['asp_player_offsides'], 3); $results[$key]['finale_tamx_ofs'] = $tamx; $results[$key]['finale_calc_ofs'] = $final; - $this->players[$k]['ofs'] = $final > $tamx ? $final : $tamx; + $this->players[$k]['ofs'] = (float) $final > (float) $tamx ? $final : $tamx; $tamx = number_format($map[$pos]['tsh'], 3); $final = number_format($result['asp_player_total_shots'], 3); $results[$key]['finale_tamx_tsh'] = $tamx; $results[$key]['finale_calc_tsh'] = $final; - $this->players[$k]['tsh'] = $final > $tamx ? $final : $tamx; + $this->players[$k]['tsh'] = (float) $final > (float) $tamx ? $final : $tamx; $tamx = number_format($map[$pos]['snt'], 3); $final = number_format($result['asp_player_shots_on_target'], 3); $results[$key]['finale_tamx_snt'] = $tamx; $results[$key]['finale_calc_snt'] = $final; - $this->players[$k]['snt'] = $final > $tamx ? $final : $tamx; + $this->players[$k]['snt'] = (float) $final > (float) $tamx ? $final : $tamx; } } } $this->calculationVariables = $results; - $this->dispatch('update-players', players: $this->players); }