centralized grapper tournaments wi
This commit is contained in:
1 parent
34701ecbff
commit
db917bdc92
8 files changed
+379
-173
No files matched your search
@@ -2,17 +2,12 @@
|
||||
|
||||
namespace App\Traits\Sofascore;
|
||||
|
||||
use App\Models\Country;
|
||||
use App\Models\SofaScoreCategory;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
use App\Models\SofaScoreEventGrapped;
|
||||
use App\Models\SofaScoreRosa;
|
||||
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;
|
||||
@@ -97,16 +92,16 @@ trait GrappingHelper
|
||||
{
|
||||
switch ($grapperSelected) {
|
||||
case 'daily':
|
||||
$this->data_dir = storage_path($this->base_dir) . '/daily';
|
||||
$this->data_dir = storage_path($this->base_dir).'/daily';
|
||||
break;
|
||||
case 'range':
|
||||
$this->data_dir = storage_path($this->base_dir) . '/range';
|
||||
$this->data_dir = storage_path($this->base_dir).'/range';
|
||||
break;
|
||||
case 'rose':
|
||||
$this->data_dir = storage_path($this->base_dir) . '/rose';
|
||||
$this->data_dir = storage_path($this->base_dir).'/rose';
|
||||
break;
|
||||
case 'player':
|
||||
$this->data_dir = storage_path($this->base_dir) . '/player';
|
||||
$this->data_dir = storage_path($this->base_dir).'/player';
|
||||
break;
|
||||
case 'excel':
|
||||
case 'mail':
|
||||
@@ -125,6 +120,12 @@ trait GrappingHelper
|
||||
*/
|
||||
protected function load_tournaments_requested(string $grapperSelected)
|
||||
{
|
||||
/**
|
||||
* SofaScoreDayTournament
|
||||
*/
|
||||
if ($this->debug) {
|
||||
Notice::note('get tournaments for grapper', 'g');
|
||||
}
|
||||
switch ($grapperSelected) {
|
||||
case 'daily':
|
||||
$this->tournaments_requested = SofaScoreTaskTournament::with('tournament')->where('sofa_score_task_id', 1)->where('disabled', false)->get()->toArray();
|
||||
@@ -217,20 +218,33 @@ trait GrappingHelper
|
||||
|
||||
protected function get_tree(string $dir, &$results = [])
|
||||
{
|
||||
$files = scandir($dir);
|
||||
foreach ($files as $value) {
|
||||
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
|
||||
if (! is_dir($path)) {
|
||||
$results[] = $path;
|
||||
} elseif ($value != '.' && $value != '..') {
|
||||
self::get_tree($path, $results);
|
||||
$results[] = $path;
|
||||
if (File::isDirectory($dir)) {
|
||||
$files = scandir($dir);
|
||||
foreach ($files as $value) {
|
||||
$path = realpath($dir.DIRECTORY_SEPARATOR.$value);
|
||||
if (! is_dir($path)) {
|
||||
$results[] = $path;
|
||||
} elseif ($value != '.' && $value != '..') {
|
||||
self::get_tree($path, $results);
|
||||
$results[] = $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
protected function grapped(string $string)
|
||||
{
|
||||
foreach ($this->grapped_files as $file) {
|
||||
if (strpos($file, $string) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function clean_string(string $string)
|
||||
{
|
||||
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
|
||||
@@ -242,7 +256,7 @@ trait GrappingHelper
|
||||
|
||||
protected function clear_folder(string $folder, $what = '')
|
||||
{
|
||||
$mainFolder = storage_path($this->base_dir . '/' . $folder);
|
||||
$mainFolder = storage_path($this->base_dir.'/'.$folder);
|
||||
|
||||
if (! $what) {
|
||||
$what = $this->select_what_delete();
|
||||
@@ -273,8 +287,8 @@ trait GrappingHelper
|
||||
$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));
|
||||
->reject(fn (string $file) => $file === '.gitignore')
|
||||
->reject(fn (string $file) => in_array($file, $tasks))
|
||||
->each(fn ($file) => Storage::disk('public')->delete($file));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user