This commit is contained in:
salam committed 2026-10-01 15:10:40 +02:00
1 parent 78db21c71c
commit e1f3b728a9
9 files changed
+252 -203

No files matched your search

+45 -11
View File
@@ -4,6 +4,7 @@ namespace App\Traits\Sofascore;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\File;
use function Laravel\Prompts\select;
use function Laravel\Prompts\text;
@@ -62,9 +63,7 @@ trait GrapSofascore
switch ($grapperSelected) {
case 'daily':
$this->task_id = 1;
$this->days_back = (int) $this->select_day();
$this->run_daily($grapperSelected);
break;
@@ -76,16 +75,19 @@ trait GrapSofascore
case 'settings':
$this->settings_to_local();
break;
case 'excel':
$folder = $this->select_folder();
$this->import_to_excel($folder);
break;
case 'mail':
$folder = $this->select_folder();
$this->send($folder);
break;
case 'clear':
$folder = $this->select_folder();
@@ -117,7 +119,16 @@ trait GrapSofascore
$this->load_tournaments_requested($folder);
$this->clear_folder($folder, 'all');
$restart = $this->ask_restart();
switch ($restart) {
case 'restart':
$this->restart = 1;
break;
case 'clear':
$this->restart = 1;
$this->clear_folder($folder, 'all');
break;
}
/**
* day 1
@@ -196,12 +207,18 @@ trait GrapSofascore
$this->set_base_dir($folder);
$restart = $this->ask_restart();
if ($restart == 'yes') {
$this->restart = 1;
$this->clear_folder($folder, 'all');
switch ($restart) {
case 'restart':
$this->restart = 1;
break;
case 'clear':
$this->restart = 1;
$this->clear_folder($folder, 'all');
break;
}
$day_done = $this->days_done();
$this->load_tournaments_requested($folder);
$this->load_days($folder);
@@ -213,10 +230,16 @@ trait GrapSofascore
Notice::note("$key/$count", 'br');
}
$this->grap_tournaments_for_day($day);
if (in_array($day, $day_done)) {
if ($this->debug) {
Notice::note("$day already in folder", 'br');
}
} else {
$this->grap_tournaments_for_day($day);
foreach ($this->tournaments_requested as $tournament) {
$this->get_event($day, $tournament);
foreach ($this->tournaments_requested as $tournament) {
$this->get_event($day, $tournament);
}
}
}
@@ -225,6 +248,16 @@ trait GrapSofascore
Notice::note('Done', 'g');
}
protected function days_done(): array
{
$directories = File::directories($this->data_dir);
$arr = [];
foreach ($directories as $directory) {
$arr[] = substr(strrchr($directory, "/"), 1);
}
return $arr;
}
/**
* Summary of select_grapper
*/
@@ -279,8 +312,9 @@ trait GrapSofascore
label: 'Restart Grapper?',
default: 'no',
options: [
'yes' => 'Yes',
'no' => 'No',
'restart' => 'Restart',
'clear' => 'Clear folder and restart',
]
);
}