grapper with flaresolverr in docker
This commit is contained in:
1 parent
911b515021
commit
8325f3a334
6 files changed
+47
-11
No files matched your search
@@ -16,7 +16,7 @@ class SofaScoreDataMail extends Mailable
|
|||||||
/**
|
/**
|
||||||
* Create a new message instance.
|
* 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.
|
* Get the message envelope.
|
||||||
@@ -37,7 +37,6 @@ class SofaScoreDataMail extends Mailable
|
|||||||
markdown: 'mail.user.sofascore_data',
|
markdown: 'mail.user.sofascore_data',
|
||||||
with: [
|
with: [
|
||||||
'message' => $this->header,
|
'message' => $this->header,
|
||||||
'table' => $this->table,
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ trait GrapSofascore
|
|||||||
{
|
{
|
||||||
use GrapperEvent;
|
use GrapperEvent;
|
||||||
use GrappingHelper;
|
use GrappingHelper;
|
||||||
|
use GrappingMail;
|
||||||
use GrappingToExcel;
|
use GrappingToExcel;
|
||||||
|
|
||||||
protected int $debug;
|
protected int $debug;
|
||||||
@@ -67,6 +68,11 @@ trait GrapSofascore
|
|||||||
|
|
||||||
$this->import_to_excel($folder);
|
$this->import_to_excel($folder);
|
||||||
break;
|
break;
|
||||||
|
case 'mail':
|
||||||
|
$folder = $this->select_folder();
|
||||||
|
|
||||||
|
$this->send($folder);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -123,6 +129,7 @@ trait GrapSofascore
|
|||||||
'player' => 'Player',
|
'player' => 'Player',
|
||||||
'settings' => 'Settings',
|
'settings' => 'Settings',
|
||||||
'excel' => 'Excel',
|
'excel' => 'Excel',
|
||||||
|
'mail' => 'Send Mail',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -133,7 +140,7 @@ trait GrapSofascore
|
|||||||
protected function select_folder(): string
|
protected function select_folder(): string
|
||||||
{
|
{
|
||||||
return select(
|
return select(
|
||||||
label: 'What folder should be imported?',
|
label: 'What folder should be used?',
|
||||||
scroll: 10,
|
scroll: 10,
|
||||||
options: [
|
options: [
|
||||||
'daily' => 'Daily',
|
'daily' => 'Daily',
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ trait GrappingHelper
|
|||||||
$this->data_dir = storage_path($this->base_dir).'/player';
|
$this->data_dir = storage_path($this->base_dir).'/player';
|
||||||
break;
|
break;
|
||||||
case 'excel':
|
case 'excel':
|
||||||
|
case 'mail':
|
||||||
$this->data_dir = storage_path($this->base_dir);
|
$this->data_dir = storage_path($this->base_dir);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Traits;
|
||||||
|
|
||||||
|
use App\Mail\SofaScoreDataMail;
|
||||||
|
use App\Utilities\Notice;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
|
trait GrappingMail
|
||||||
|
{
|
||||||
|
public function send(string $folder)
|
||||||
|
{
|
||||||
|
ini_set('memory_limit', -1);
|
||||||
|
|
||||||
|
if ($this->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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ trait GrappingToExcel
|
|||||||
}
|
}
|
||||||
|
|
||||||
$titel = ucfirst($folder).'_'.Carbon::now()->format('Y-m-d');
|
$titel = ucfirst($folder).'_'.Carbon::now()->format('Y-m-d');
|
||||||
|
|
||||||
$files = $this->get_tree("$this->data_dir/$folder");
|
$files = $this->get_tree("$this->data_dir/$folder");
|
||||||
|
|
||||||
$files = array_chunk($this->filter($files), self::$max);
|
$files = array_chunk($this->filter($files), self::$max);
|
||||||
@@ -66,7 +67,7 @@ trait GrappingToExcel
|
|||||||
|
|
||||||
$spreadsheet->setActiveSheetIndex(0);
|
$spreadsheet->setActiveSheetIndex(0);
|
||||||
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
|
||||||
$writer->save("$titel-$from-$to.xlsx");
|
$writer->save("$this->data_dir/$folder/$titel-$from-$to.xlsx");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,4 @@
|
|||||||
@component('mail::message')
|
@component('mail::message')
|
||||||
# {{ $message }}
|
# {{ $message }}
|
||||||
|
|
||||||
@component('mail::table')
|
|
||||||
| Liga | Event | Starttime |
|
|
||||||
|:------------- |:-------------| --------:|
|
|
||||||
{{ $table }}
|
|
||||||
@endcomponent
|
|
||||||
|
|
||||||
@endcomponent
|
@endcomponent
|
||||||
|
|
||||||
Reference in new issue
Block a user