This commit is contained in:
salam committed 2026-09-27 19:43:26 +02:00
1 parent 31dd27dd73
commit 254ca94d73
4 files changed
+80 -237

No files matched your search

+65 -19
View File
@@ -70,7 +70,7 @@ trait GrapSofascore
case 'range':
$this->task_id = 3;
$this->run_range($grapperSelected);
$this->range_grapper_nobreak();
break;
case 'settings':
@@ -91,6 +91,10 @@ trait GrapSofascore
$this->clear_folder($folder);
break;
case 'delete_orphants':
$this->delete_imported_files_orphants();
break;
}
break;
}
@@ -116,17 +120,17 @@ trait GrapSofascore
/**
* day 1
*/
// $this->clear_folder($folder, 'all');
$this->clear_folder($folder, 'all');
// $day = Carbon::now()->subDay()->format('Y-m-d');
$day = Carbon::now()->subDay()->format('Y-m-d');
// $this->grap_tournaments_for_day($day);
$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);
}
// $this->import_to_excel($day, "Daily-$day");
$this->import_to_excel($folder, $day);
/**
* day 5
@@ -135,13 +139,13 @@ trait GrapSofascore
$day = Carbon::now()->subDays(5)->format('Y-m-d');
// $this->grap_tournaments_for_day($day);
$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);
}
$this->import_to_excel($day, "Daily-$day");
$this->import_to_excel($folder, $day);
$this->send($folder);
}
@@ -176,16 +180,45 @@ trait GrapSofascore
/**
* Summary of run_range
*
* @return never
*/
protected function run_range(string $grapperSelected)
protected function range_grapper_nobreak()
{
$this->load_tournaments_requested($grapperSelected);
$folder = 'range';
$this->load_days($grapperSelected);
$this->task_id = 3;
dd($this->days);
$this->set_base_dir($folder);
$restart = $this->ask_restart();
if ($restart == 'yes') {
$this->restart = 1;
$this->clear_folder($folder, 'all');
}
$this->load_tournaments_requested($folder);
$this->load_days($folder);
$count = \count($this->days);
foreach ($this->days as $key => $day) {
if ($this->debug) {
$key++;
Notice::note("$key/$count", 'br');
}
$this->grap_tournaments_for_day($day);
foreach ($this->tournaments_requested as $tournament) {
$this->get_event($day, $tournament);
}
}
Notice::note('Excel', 'g');
$this->import_to_excel($folder, $day);
Notice::note('Done', 'g');
}
/**
@@ -205,6 +238,7 @@ trait GrapSofascore
'excel' => 'Excel',
'mail' => 'Send Mail',
'clear' => 'Empty Folder',
'delete_orphants' => 'Delete Imported Orphants',
]
);
}
@@ -235,6 +269,18 @@ trait GrapSofascore
);
}
protected function ask_restart(): string
{
return select(
label: 'Restart Grapper?',
default: 'no',
options: [
'yes' => 'Yes',
'no' => 'No',
]
);
}
protected function select_what_delete(): string
{
return select(
+15 -1
View File
@@ -11,11 +11,13 @@ use App\Models\SofaScoreTask;
use App\Models\SofaScoreTaskDay;
use App\Models\SofaScoreTaskTournament;
use App\Models\SofaScoreTournament;
use App\Models\StatistikoImport;
use App\Services\CloudflareSolverService;
use App\Utilities\Notice;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Storage;
trait GrappingHelper
{
@@ -125,9 +127,11 @@ trait GrappingHelper
{
switch ($grapperSelected) {
case 'daily':
case 'range':
$this->tournaments_requested = SofaScoreTaskTournament::with('tournament')->where('sofa_score_task_id', 1)->where('disabled', false)->get()->toArray();
break;
case 'range':
$this->tournaments_requested = SofaScoreTaskTournament::with('tournament')->where('sofa_score_task_id', 3)->where('disabled', false)->get()->toArray();
break;
}
}
@@ -420,4 +424,14 @@ trait GrappingHelper
break;
}
}
protected function delete_imported_files_orphants(): void
{
$tasks = StatistikoImport::pluck('file_name')->toArray();
collect(Storage::disk('public')->allFiles('statistiko'))
->reject(fn (string $file) => $file === '.gitignore')
->reject(fn (string $file) => in_array($file, $tasks))
->each(fn ($file) => Storage::disk('public')->delete($file));
}
}