wip
This commit is contained in:
1 parent
267b5b9583
commit
911b515021
15 files changed
+1048
-56
No files matched your search
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use App\Utilities\Notice;
|
||||
|
||||
use function Laravel\Prompts\select;
|
||||
|
||||
trait GrapSofascore
|
||||
{
|
||||
use GrapperEvent;
|
||||
use GrappingHelper;
|
||||
use GrappingToExcel;
|
||||
|
||||
protected int $debug;
|
||||
|
||||
protected int $restart;
|
||||
|
||||
protected int $force;
|
||||
|
||||
protected int $task_id;
|
||||
|
||||
protected array $daily_days = [1, 5];
|
||||
|
||||
protected string $base_dir = 'sofascore_data';
|
||||
|
||||
protected string $data_dir = '';
|
||||
|
||||
protected string $base_url = 'https://www.sofascore.com/';
|
||||
|
||||
protected array $tournaments_requested = [];
|
||||
|
||||
protected array $days = [];
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
error_reporting(E_ALL);
|
||||
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
$this->debug = $this->options()['d'] ?? 0;
|
||||
|
||||
$this->restart = $this->options()['r'] ?? 0;
|
||||
|
||||
$this->force = $this->options()['f'] ?? 0;
|
||||
|
||||
$grapperSelected = $this->select_grapper();
|
||||
|
||||
$this->set_base_dir($grapperSelected);
|
||||
|
||||
switch ($grapperSelected) {
|
||||
case 'daily':
|
||||
$this->task_id = 1;
|
||||
$this->run_daily($grapperSelected);
|
||||
break;
|
||||
|
||||
case 'range':
|
||||
$this->task_id = 3;
|
||||
$this->run_range($grapperSelected);
|
||||
break;
|
||||
|
||||
case 'settings':
|
||||
$this->settings_to_local();
|
||||
break;
|
||||
case 'excel':
|
||||
$folder = $this->select_folder();
|
||||
|
||||
$this->import_to_excel($folder);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of run_daily
|
||||
*/
|
||||
protected function run_daily(string $grapperSelected)
|
||||
{
|
||||
$this->load_tournaments_requested($grapperSelected);
|
||||
|
||||
$this->load_days($grapperSelected);
|
||||
|
||||
foreach ($this->days as $day) {
|
||||
|
||||
$this->grap_tournaments_for_day($day);
|
||||
|
||||
foreach ($this->tournaments_requested as $tournament) {
|
||||
$this->get_event($day, $tournament);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->debug) {
|
||||
Notice::note('Day grapping compleated', 'g');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of run_range
|
||||
*
|
||||
* @return never
|
||||
*/
|
||||
protected function run_range(string $grapperSelected)
|
||||
{
|
||||
$this->load_tournaments_requested($grapperSelected);
|
||||
|
||||
$this->load_days($grapperSelected);
|
||||
|
||||
dd($this->days);
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of select_grapper
|
||||
*/
|
||||
protected function select_grapper(): string
|
||||
{
|
||||
return select(
|
||||
label: 'What task should run?',
|
||||
scroll: 10,
|
||||
options: [
|
||||
'daily' => 'Daily',
|
||||
'range' => 'Range',
|
||||
'rose' => 'Rose',
|
||||
'player' => 'Player',
|
||||
'settings' => 'Settings',
|
||||
'excel' => 'Excel',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary of select_folder
|
||||
*/
|
||||
protected function select_folder(): string
|
||||
{
|
||||
return select(
|
||||
label: 'What folder should be imported?',
|
||||
scroll: 10,
|
||||
options: [
|
||||
'daily' => 'Daily',
|
||||
'range' => 'Range',
|
||||
'rose' => 'Rose',
|
||||
'player' => 'Player',
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user