wip
This commit is contained in:
1 parent
db98383da0
commit
2085d0f512
6 files changed
+70
-21
No files matched your search
@@ -5,6 +5,7 @@ namespace App\Console\Commands;
|
||||
use App\Console\Commands\Grapper\Sofascore\Grapper;
|
||||
use App\Console\Commands\Grapper\Sofascore\GrapperTest;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\ClearDir;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\RemoveDir;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\SetStorage;
|
||||
use App\Console\Commands\Grapper\Sofascore\MakeExcel;
|
||||
use App\Console\Commands\Grapper\Sofascore\Rose;
|
||||
@@ -28,7 +29,7 @@ class Grap extends Command
|
||||
|
||||
public static string $useragent = '4';
|
||||
|
||||
protected $signature = 'grp {id=0} {day=0} {--date=} {--folder=} {--d} {--r} {--m} {--f} {--R} {--S}';
|
||||
protected $signature = 'grp {id=0} {day=0} {--date=} {--folder=} {--d} {--g} {--r} {--c} {--m} {--f} {--F} {--R} {--S}';
|
||||
|
||||
public function handle()
|
||||
{
|
||||
@@ -41,8 +42,11 @@ class Grap extends Command
|
||||
$txt = 'PARAMETERS' . PHP_EOL;
|
||||
$txt .= '--d debug' . PHP_EOL;
|
||||
$txt .= '--r restart range' . PHP_EOL;
|
||||
$txt .= '--f force' . PHP_EOL;
|
||||
$txt .= '--f force Events' . PHP_EOL;
|
||||
$txt .= '--F force DayTournament links' . PHP_EOL;
|
||||
$txt .= '--c clear grap dir' . PHP_EOL;
|
||||
$txt .= '--m mail only' . PHP_EOL;
|
||||
$txt .= '--g grap & excel only' . PHP_EOL;
|
||||
$txt .= '--R read file' . PHP_EOL;
|
||||
$txt .= '--S save to file' . PHP_EOL;
|
||||
$txt .= '--folder' . PHP_EOL;
|
||||
@@ -66,7 +70,8 @@ class Grap extends Command
|
||||
case 1:
|
||||
// DAILY
|
||||
SetStorage::set(1);
|
||||
// MoveToArchive::move(1);
|
||||
|
||||
RemoveDir::remove();
|
||||
|
||||
// with --m just resend mail
|
||||
if (! self::$options['m']) {
|
||||
@@ -74,21 +79,31 @@ class Grap extends Command
|
||||
MakeExcel::create();
|
||||
}
|
||||
|
||||
SendMail::run(1);
|
||||
// with --g just grap & excel
|
||||
if (! self::$options['g']) {
|
||||
SendMail::run(1);
|
||||
}
|
||||
|
||||
break;
|
||||
case 2:
|
||||
// LAST 3 DAYS
|
||||
SetStorage::set(2);
|
||||
self::$options['f'] = 1;
|
||||
|
||||
ClearDir::clear();
|
||||
if (self::$options['c']) {
|
||||
ClearDir::clear();
|
||||
}
|
||||
|
||||
Grapper::load(2);
|
||||
self::$options['day'] = 1;
|
||||
SetStorage::set(1);
|
||||
Grapper::load(1);
|
||||
MakeExcel::create('day');
|
||||
|
||||
MakeExcel::create();
|
||||
self::$options['day'] = 5;
|
||||
SetStorage::set(1);
|
||||
Grapper::load(1);
|
||||
MakeExcel::create('day');
|
||||
|
||||
SendMail::run(1);
|
||||
|
||||
break;
|
||||
case 3:
|
||||
// RANGE
|
||||
|
||||
@@ -26,7 +26,7 @@ class DaysTournament
|
||||
public static function get(string $day)
|
||||
{
|
||||
$debug = Grap::$options['d'] ?? 0;
|
||||
$force = Grap::$options['f'] ?? 0;
|
||||
$force = Grap::$options['F'] ?? 0;
|
||||
|
||||
$tournaments_counter = 0;
|
||||
|
||||
|
||||
@@ -8,16 +8,21 @@ use Illuminate\Filesystem\Filesystem;
|
||||
|
||||
class ClearDir
|
||||
{
|
||||
public static function clear(): void
|
||||
public static function clear($dir = ''): void
|
||||
{
|
||||
$file = new Filesystem;
|
||||
$debug = Grap::$options['d'];
|
||||
|
||||
$file = new Filesystem;
|
||||
|
||||
$file->cleanDirectory(Grap::$storage);
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('Directory: ' . Grap::$storage . ' - All content cleard', 'p');
|
||||
if ($dir) {
|
||||
$file->cleanDirectory($dir);
|
||||
if ($debug) {
|
||||
Notice::note('Dir: ' . $dir . ' - removed', 'p');
|
||||
}
|
||||
} else {
|
||||
$file->cleanDirectory(Grap::$storage);
|
||||
if ($debug) {
|
||||
Notice::note('Dir: ' . Grap::$storage . ' - content deleted', 'p');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Helper;
|
||||
|
||||
use App\Console\Commands\Grap;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class RemoveDir
|
||||
{
|
||||
public static function remove(): void
|
||||
{
|
||||
$debug = Grap::$options['d'];
|
||||
|
||||
// Deletes the directory and everything inside it relative to the disk root
|
||||
|
||||
Storage::deleteDirectory(Grap::$storage . '/' . Grap::$folder);
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('Directory: ' . Grap::$storage . '/' . Grap::$folder . ' removed', 'p');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ class SetStorage
|
||||
|
||||
$date = Grap::$options['date'] ?? '';
|
||||
|
||||
$day = Grap::$options['day'] == 0 ? 2 : Grap::$options['day'];
|
||||
$day = Grap::$options['day'] ?? 1;
|
||||
|
||||
// must be connectet to task for activated ligas
|
||||
$task = SofaScoreTask::where('id', $task_id)->first();
|
||||
@@ -62,6 +62,7 @@ class SetStorage
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(Grap::$storage, 'g');
|
||||
Notice::note(Grap::$folder, 'g');
|
||||
if (!$force) {
|
||||
sleep(4);
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class MakeExcel
|
||||
{
|
||||
public static $max = 1000;
|
||||
public static $max = 2000;
|
||||
|
||||
public static function create()
|
||||
public static function create(string $what = '')
|
||||
{
|
||||
ini_set('memory_limit', -1);
|
||||
|
||||
@@ -23,7 +23,12 @@ class MakeExcel
|
||||
Notice::note("Make Excel");
|
||||
}
|
||||
|
||||
$files = ReadDir::get_tree(Grap::$storage);
|
||||
if ($what == 'day') {
|
||||
$files = ReadDir::get_tree(Grap::$storage . '/' . Grap::$folder);
|
||||
} else {
|
||||
$files = ReadDir::get_tree(Grap::$storage);
|
||||
}
|
||||
|
||||
|
||||
$files = array_chunk(FileType::filter($files), self::$max);
|
||||
|
||||
|
||||
Reference in new issue
Block a user