From 8325f3a33474e0bf033fc55ce3644a59e2406f56 Mon Sep 17 00:00:00 2001 From: salam Date: Sat, 26 Sep 2026 18:19:30 +0200 Subject: [PATCH] grapper with flaresolverr in docker --- app/Mail/SofaScoreDataMail.php | 3 +- app/Traits/GrapSofascore.php | 9 ++++- app/Traits/GrappingHelper.php | 1 + app/Traits/GrappingMail.php | 35 +++++++++++++++++++ app/Traits/GrappingToExcel.php | 3 +- .../views/mail/user/sofascore_data.blade.php | 7 ---- 6 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 app/Traits/GrappingMail.php diff --git a/app/Mail/SofaScoreDataMail.php b/app/Mail/SofaScoreDataMail.php index 308d5890..a0436211 100644 --- a/app/Mail/SofaScoreDataMail.php +++ b/app/Mail/SofaScoreDataMail.php @@ -16,7 +16,7 @@ class SofaScoreDataMail extends Mailable /** * Create a new message instance. */ - public function __construct(public string $header, public string $table, public array $sendfiles) {} + public function __construct(public string $header, public array $sendfiles) {} /** * Get the message envelope. @@ -37,7 +37,6 @@ class SofaScoreDataMail extends Mailable markdown: 'mail.user.sofascore_data', with: [ 'message' => $this->header, - 'table' => $this->table, ], ); } diff --git a/app/Traits/GrapSofascore.php b/app/Traits/GrapSofascore.php index b7d35236..9e6b6960 100644 --- a/app/Traits/GrapSofascore.php +++ b/app/Traits/GrapSofascore.php @@ -10,6 +10,7 @@ trait GrapSofascore { use GrapperEvent; use GrappingHelper; + use GrappingMail; use GrappingToExcel; protected int $debug; @@ -67,6 +68,11 @@ trait GrapSofascore $this->import_to_excel($folder); break; + case 'mail': + $folder = $this->select_folder(); + + $this->send($folder); + break; } } @@ -123,6 +129,7 @@ trait GrapSofascore 'player' => 'Player', 'settings' => 'Settings', 'excel' => 'Excel', + 'mail' => 'Send Mail', ] ); } @@ -133,7 +140,7 @@ trait GrapSofascore protected function select_folder(): string { return select( - label: 'What folder should be imported?', + label: 'What folder should be used?', scroll: 10, options: [ 'daily' => 'Daily', diff --git a/app/Traits/GrappingHelper.php b/app/Traits/GrappingHelper.php index a4d2b5b7..9b8a1de7 100644 --- a/app/Traits/GrappingHelper.php +++ b/app/Traits/GrappingHelper.php @@ -109,6 +109,7 @@ trait GrappingHelper $this->data_dir = storage_path($this->base_dir).'/player'; break; case 'excel': + case 'mail': $this->data_dir = storage_path($this->base_dir); break; } diff --git a/app/Traits/GrappingMail.php b/app/Traits/GrappingMail.php new file mode 100644 index 00000000..40d8efca --- /dev/null +++ b/app/Traits/GrappingMail.php @@ -0,0 +1,35 @@ +debug) { + Notice::note("Eend excel files from folder $folder", 'b'); + } + + $files = $this->get_tree("$this->data_dir/$folder"); + + $sendfiles = $this->filter($files, ['xlsx']); + + $header = ucfirst($folder).' '.Carbon::now()->format('Y-m-d'); + + Mail::to('hermann.telser@gmail.com') + ->cc('ubaldo.perrucci@gmail.com') + ->send( + new SofaScoreDataMail($header, $sendfiles) + ); + if ($this->debug) { + Notice::note('✉ Mail Send', 'bg'); + } + } +} diff --git a/app/Traits/GrappingToExcel.php b/app/Traits/GrappingToExcel.php index 331384d2..d37f0185 100644 --- a/app/Traits/GrappingToExcel.php +++ b/app/Traits/GrappingToExcel.php @@ -20,6 +20,7 @@ trait GrappingToExcel } $titel = ucfirst($folder).'_'.Carbon::now()->format('Y-m-d'); + $files = $this->get_tree("$this->data_dir/$folder"); $files = array_chunk($this->filter($files), self::$max); @@ -66,7 +67,7 @@ trait GrappingToExcel $spreadsheet->setActiveSheetIndex(0); $writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); - $writer->save("$titel-$from-$to.xlsx"); + $writer->save("$this->data_dir/$folder/$titel-$from-$to.xlsx"); } } diff --git a/resources/views/mail/user/sofascore_data.blade.php b/resources/views/mail/user/sofascore_data.blade.php index 8e058a9f..2550c825 100644 --- a/resources/views/mail/user/sofascore_data.blade.php +++ b/resources/views/mail/user/sofascore_data.blade.php @@ -1,11 +1,4 @@ @component('mail::message') # {{ $message }} - -@component('mail::table') -| Liga | Event | Starttime | -|:------------- |:-------------| --------:| -{{ $table }} -@endcomponent - @endcomponent