wip
This commit is contained in:
1 parent
2b591ad8cf
commit
ad0724f61b
8 files changed
+145
-117
No files matched your search
@@ -2,21 +2,21 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\Grapper;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Strings;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\ZipFolder;
|
||||
use App\Console\Commands\Grapper\Sofascore\MakeExcel;
|
||||
use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason;
|
||||
use App\Console\Commands\Grapper\Sofascore\Rose;
|
||||
use App\Console\Commands\Grapper\Sofascore\SendMail;
|
||||
use App\Console\Commands\Grapper\Sofascore\SettingsToLocal;
|
||||
use App\Console\Commands\Grapper\Sofascore\SettingsToProduction;
|
||||
use App\Console\Commands\Grapper\Sofascore\SqlMover;
|
||||
use App\Console\Commands\Grapper\Sofascore\TournamentTeams;
|
||||
use App\Utilities\Notice;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreTask;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Console\Commands\Grapper\Sofascore\Rose;
|
||||
use App\Console\Commands\Grapper\Sofascore\Grapper;
|
||||
use App\Console\Commands\Grapper\Sofascore\SendMail;
|
||||
use App\Console\Commands\Grapper\Sofascore\SqlMover;
|
||||
use App\Console\Commands\Grapper\Sofascore\MakeExcel;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Strings;
|
||||
use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason;
|
||||
use App\Console\Commands\Grapper\Sofascore\SettingsToLocal;
|
||||
use App\Console\Commands\Grapper\Sofascore\TournamentTeams;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\ZipFolder;
|
||||
use App\Console\Commands\Grapper\Sofascore\SettingsToProduction;
|
||||
|
||||
ini_set('magic_quotes_runtime', false);
|
||||
|
||||
@@ -34,56 +34,55 @@ class Sofascore
|
||||
{
|
||||
$function = Nuh::$options['fun'];
|
||||
|
||||
|
||||
switch ($function) {
|
||||
|
||||
case 1:
|
||||
case 'player_season':
|
||||
PlayerPerSeason::run();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case 'set_to_local':
|
||||
SettingsToLocal::run();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
case 'grapper':
|
||||
self::setStorage();
|
||||
Grapper::load();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
case 'zip':
|
||||
self::setStorage();
|
||||
ZipFolder::create();
|
||||
break;
|
||||
|
||||
case 5:
|
||||
case 'mail':
|
||||
self::setStorage();
|
||||
SendMail::run();
|
||||
break;
|
||||
|
||||
case 6:
|
||||
case 'rose':
|
||||
self::setStorage();
|
||||
Rose::run();
|
||||
break;
|
||||
|
||||
case 7:
|
||||
case 'sql_mover':
|
||||
SqlMover::run();
|
||||
break;
|
||||
|
||||
case 8:
|
||||
case 'excel':
|
||||
self::setStorage();
|
||||
MakeExcel::create();
|
||||
break;
|
||||
|
||||
case 9:
|
||||
case 'torunament_teams':
|
||||
TournamentTeams::get();
|
||||
break;
|
||||
|
||||
case 10:
|
||||
case 'set_to_production':
|
||||
SettingsToProduction::run();
|
||||
break;
|
||||
|
||||
default:
|
||||
Notice::note('id not valid', 'br', 1);
|
||||
Notice::note('not a valid fuction', 'br', 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,36 +90,39 @@ class Sofascore
|
||||
{
|
||||
$task = Nuh::$options['task'];
|
||||
$debug = Nuh::$options['d'];
|
||||
$folder = Nuh::$options['folder'];
|
||||
|
||||
$sofascore_data = storage_path('sofascore_data') . '/';
|
||||
$task = SofaScoreTask::where('id', $task)->first();
|
||||
if (!$task) {
|
||||
Notice::note("No SofaScoreTask " . Nuh::$options['task'], 'r', 1);
|
||||
}
|
||||
$storage_name = Strings::clean($task->name);
|
||||
if ($task) {
|
||||
$storage_name = Strings::clean($task->name);
|
||||
|
||||
switch ($task->id) {
|
||||
case 1:
|
||||
self::$storage = $sofascore_data . $storage_name;
|
||||
self::$folder = Carbon::now()->subDays(3)->format('Y-m-d');
|
||||
break;
|
||||
case 2:
|
||||
self::$storage = $sofascore_data . $storage_name . '/' . $task->day_from;
|
||||
self::$zipfile = $sofascore_data . $storage_name . '/' . $task->day_from . '.zip';
|
||||
break;
|
||||
case 3:
|
||||
self::$storage = $sofascore_data . $storage_name . '-' . $task->day_from . '-' . $task->day_to;
|
||||
self::$zipfile = $sofascore_data . $storage_name . '-' . $task->day_from . '-' . $task->day_to . '.zip';
|
||||
break;
|
||||
case 4:
|
||||
self::$storage = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d');
|
||||
self::$zipfile = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d') . '.zip';
|
||||
break;
|
||||
switch ($task->id) {
|
||||
case 1:
|
||||
self::$storage = $sofascore_data . $storage_name;
|
||||
self::$folder = Carbon::now()->subDays(3)->format('Y-m-d');
|
||||
break;
|
||||
case 2:
|
||||
self::$storage = $sofascore_data . $storage_name . '/' . $task->day_from;
|
||||
self::$zipfile = $sofascore_data . $storage_name . '/' . $task->day_from . '.zip';
|
||||
break;
|
||||
case 3:
|
||||
self::$storage = $sofascore_data . $storage_name . '-' . $task->day_from . '-' . $task->day_to;
|
||||
self::$zipfile = $sofascore_data . $storage_name . '-' . $task->day_from . '-' . $task->day_to . '.zip';
|
||||
break;
|
||||
case 4:
|
||||
self::$storage = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d');
|
||||
self::$zipfile = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d') . '.zip';
|
||||
break;
|
||||
|
||||
default:
|
||||
self::$storage = $sofascore_data . $storage_name;
|
||||
self::$zipfile = $sofascore_data . $storage_name . '/archive.zip';
|
||||
break;
|
||||
default:
|
||||
self::$storage = $sofascore_data . $storage_name;
|
||||
self::$zipfile = $sofascore_data . $storage_name . '/archive.zip';
|
||||
break;
|
||||
}
|
||||
} else if ($folder) {
|
||||
self::$storage = $sofascore_data;
|
||||
self::$folder = $folder;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Utilities\Notice;
|
||||
use App\Console\Commands\Nuh;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Models\SofaScoreTaskDay;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use App\Models\SofaScoreEventGrapped;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
use App\Models\SofaScoreTaskTournament;
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\CurlSofa;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
use App\Models\SofaScoreEventGrapped;
|
||||
use App\Models\SofaScoreTaskDay;
|
||||
use App\Models\SofaScoreTaskTournament;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class Grapper
|
||||
{
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Helper;
|
||||
|
||||
use App\Utilities\Notice;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreTask;
|
||||
use App\Models\SofaScoreTaskDay;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Models\SofaScoreTaskDay;
|
||||
|
||||
class LoadDays
|
||||
{
|
||||
@@ -18,6 +18,8 @@ class LoadDays
|
||||
|
||||
$task_id = Nuh::$options['task'] ?? 0;
|
||||
|
||||
$folder = Nuh::$options['folder'] ?? 0;
|
||||
|
||||
$dates = [];
|
||||
|
||||
if (!$task_id) {
|
||||
@@ -34,11 +36,19 @@ class LoadDays
|
||||
switch ($task->mode) {
|
||||
|
||||
case 'daily':
|
||||
$dates[] = [
|
||||
'day' => Carbon::now()->subDays(3)->format('Y-m-d'),
|
||||
'slug' => $task->sport->ss_slug,
|
||||
'sport_id' => $task->sport_id,
|
||||
];
|
||||
if ($folder) {
|
||||
$dates[] = [
|
||||
'day' => $folder,
|
||||
'slug' => $task->sport->ss_slug,
|
||||
'sport_id' => $task->sport_id,
|
||||
];
|
||||
} else {
|
||||
$dates[] = [
|
||||
'day' => Carbon::now()->subDays(3)->format('Y-m-d'),
|
||||
'slug' => $task->sport->ss_slug,
|
||||
'sport_id' => $task->sport_id,
|
||||
];
|
||||
}
|
||||
break;
|
||||
|
||||
case 'date':
|
||||
|
||||
@@ -29,11 +29,24 @@ class MakeExcel
|
||||
|
||||
foreach ($files as $key => $value) {
|
||||
|
||||
$from = $key * self::$max + 1;
|
||||
$key++;
|
||||
$to = $key * self::$max;
|
||||
$filename = Sofascore::$folder . '-' . $from . '-' . $to . '.xlsx';
|
||||
$has = count($value);
|
||||
if (!$key && $has < self::$max) {
|
||||
$from = 1;
|
||||
$to = $has;
|
||||
} else if (!$key) {
|
||||
$from = 1;
|
||||
$key++;
|
||||
$to = $key * self::$max;
|
||||
} else if ($has == self::$max) {
|
||||
$from = $key * self::$max + 1;
|
||||
$key++;
|
||||
$to = $key * self::$max;
|
||||
} else {
|
||||
$from = $key * self::$max + 1;
|
||||
$to = $key * self::$max + $has;
|
||||
}
|
||||
|
||||
$filename = Sofascore::$folder . '-' . $from . '-' . $to . '.xlsx';
|
||||
$spreadsheet = new Spreadsheet;
|
||||
$spreadsheet->getProperties()->setTitle($filename);
|
||||
$activeWorksheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
Reference in new issue
Block a user