ss ->sortable
This commit is contained in:
1 parent
c8cf1edaf4
commit
000f6fa046
18 files changed
+157
-106
No files matched your search
@@ -10,6 +10,7 @@ use App\Console\Commands\Grapper\Sofascore\SendMail;
|
||||
use App\Console\Commands\Grapper\Sofascore\SettingsToLocal;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Console\Commands\Grapper\Sofascore\Rose;
|
||||
|
||||
class Grap extends Command
|
||||
{
|
||||
@@ -40,16 +41,13 @@ class Grap extends Command
|
||||
$txt .= '--folder' . PHP_EOL;
|
||||
$txt .= '-----------------------------------------------------------' . PHP_EOL;
|
||||
$txt .= 'FUNCTION' . PHP_EOL;
|
||||
$txt .= ' 1 grapper daily & subDays ( default 3)' . PHP_EOL;
|
||||
$txt .= ' 2 grapper date' . PHP_EOL;
|
||||
$txt .= ' 3 grapper range' . PHP_EOL;
|
||||
$txt .= ' 4 grapper rose' . PHP_EOL;
|
||||
$txt .= ' 5 make ecxel from folder' . PHP_EOL;
|
||||
$txt .= ' 5 playeer/season' . PHP_EOL;
|
||||
// $txt .= " 1\tPlayerPerSeason".PHP_EOL;
|
||||
// $txt .= " 1\tPlayerPerSeason".PHP_EOL;
|
||||
// $txt .= " 1\tPlayerPerSeason".PHP_EOL;
|
||||
// $txt .= " 2\tSettingsToLocal".PHP_EOL;
|
||||
$txt .= ' 1 grapper DAILY & subDays ( default 3)' . PHP_EOL;
|
||||
$txt .= ' 2 grapper DATE' . PHP_EOL;
|
||||
$txt .= ' 3 grapper RANGE' . PHP_EOL;
|
||||
$txt .= ' 4 grapper ROSE' . PHP_EOL;
|
||||
$txt .= ' 5 import to excel from folder' . PHP_EOL;
|
||||
$txt .= ' 6 playeer/season' . PHP_EOL;
|
||||
$txt .= ' 7 settings to local' . PHP_EOL;
|
||||
Notice::note($txt, 'b', 1);
|
||||
}
|
||||
|
||||
@@ -59,8 +57,6 @@ class Grap extends Command
|
||||
switch (self::$options['id']) {
|
||||
|
||||
case 1:
|
||||
SettingsToLocal::run();
|
||||
|
||||
SetStorage::set(1);
|
||||
|
||||
Grapper::load(1);
|
||||
@@ -69,14 +65,6 @@ class Grap extends Command
|
||||
|
||||
SendMail::run(1);
|
||||
|
||||
break;
|
||||
case 5:
|
||||
SetStorage::set(5);
|
||||
|
||||
MakeExcel::create();
|
||||
break;
|
||||
case 6:
|
||||
PlayerPerSeason::run();
|
||||
break;
|
||||
// case 2:
|
||||
// SetStorage::set();
|
||||
@@ -88,11 +76,30 @@ class Grap extends Command
|
||||
|
||||
// Grapper::load(3);
|
||||
// break;
|
||||
// case 4:
|
||||
// SetStorage::set();
|
||||
case 4:
|
||||
SetStorage::set(4);
|
||||
|
||||
Rose::run();
|
||||
break;
|
||||
case 5:
|
||||
SetStorage::set(5);
|
||||
|
||||
MakeExcel::create();
|
||||
break;
|
||||
case 6:
|
||||
PlayerPerSeason::run();
|
||||
|
||||
break;
|
||||
case 7:
|
||||
|
||||
SettingsToLocal::run();
|
||||
break;
|
||||
|
||||
case 8:
|
||||
|
||||
break;
|
||||
|
||||
|
||||
// Grapper::load(4);
|
||||
// break;
|
||||
// case 5:
|
||||
|
||||
// PlayerPerSeason::run();
|
||||
|
||||
@@ -58,11 +58,7 @@ class Grapper
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('reset grapper', 'br', 1);
|
||||
}
|
||||
} else {
|
||||
if ($debug) {
|
||||
Notice::note('continuing grapper', 'bg');
|
||||
Notice::note('Restarted grapper', 'br', 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,10 +68,6 @@ class Grapper
|
||||
|
||||
foreach ($active_tournaments as $tournament) {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('START '.$tournament->tournament->name, 'p');
|
||||
}
|
||||
|
||||
$res = SofaScoreDayTournament::whereDate('day', '=', $day)->where('tournament_id', $tournament->sofa_score_tournament_id)->first();
|
||||
|
||||
if ($res) {
|
||||
@@ -84,7 +76,7 @@ class Grapper
|
||||
Notice::note($day, 'g');
|
||||
}
|
||||
|
||||
$url = Grap::$options['base_url']."api/v1/unique-tournament/$tournament->sofa_score_tournament_id/scheduled-events/$day";
|
||||
$url = Grap::$options['base_url'] . "api/v1/unique-tournament/$tournament->sofa_score_tournament_id/scheduled-events/$day";
|
||||
|
||||
Sleeper::rand(1);
|
||||
|
||||
@@ -92,13 +84,19 @@ class Grapper
|
||||
|
||||
if (isset($data['events'])) {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note($tournament->tournament->name, 'bb');
|
||||
}
|
||||
|
||||
foreach ($data['events'] as $event) {
|
||||
|
||||
dd($event);
|
||||
|
||||
Grap::$useragent = rand(1, 6);
|
||||
|
||||
if (! $force && SofaScoreEventGrapped::where('id', (int) $event['id'])->exists()) {
|
||||
if ($debug) {
|
||||
Notice::note('Grapped '.$day.' - '.$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'g');
|
||||
Notice::note('Grapped ' . $day . ' - ' . $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'], 'g');
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -113,18 +111,18 @@ class Grapper
|
||||
Sleeper::rand(1);
|
||||
|
||||
if ($debug) {
|
||||
Notice::note($day.' - '.$event['homeTeam']['name'].' vs '.$event['awayTeam']['name'], 'bg');
|
||||
Notice::note($day . ' - ' . $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'], 'bg');
|
||||
}
|
||||
|
||||
$grapped = SofaScoreEventGrapped::firstOrNew(['id' => $event['id']]);
|
||||
$grapped->grapper_id = $task_id;
|
||||
$grapped->day = $day;
|
||||
$grapped->liga = $event['tournament']['name'];
|
||||
$grapped->name = $event['homeTeam']['name'].' vs '.$event['awayTeam']['name'];
|
||||
$grapped->name = $event['homeTeam']['name'] . ' vs ' . $event['awayTeam']['name'];
|
||||
$grapped->url = $url;
|
||||
$grapped->starttime = $starttime->toDateTimeString();
|
||||
|
||||
$folder = Grap::$storage.'/'.$day.'/'.$day.'-'.$event['tournament']['slug'].'/'.$event['slug'];
|
||||
$folder = Grap::$storage . '/' . $day . '/' . $day . '-' . $event['tournament']['category']['slug'] . '-' . $event['tournament']['slug'] . '/' . $event['slug'];
|
||||
|
||||
File::makeDirectory($folder, 0775, true, true);
|
||||
|
||||
@@ -132,7 +130,7 @@ class Grapper
|
||||
* EVENT event
|
||||
*********************************/
|
||||
|
||||
File::put($folder.'/event.json', json_encode($event));
|
||||
File::put($folder . '/event.json', json_encode($event));
|
||||
|
||||
/*********************************
|
||||
* EVENT statistics
|
||||
@@ -140,7 +138,7 @@ class Grapper
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
$url = Grap::$options['base_url']."api/v1/event/$event_id/statistics";
|
||||
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/statistics";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
@@ -148,7 +146,7 @@ class Grapper
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder.'/statistics.json', json_encode($data));
|
||||
File::put($folder . '/statistics.json', json_encode($data));
|
||||
|
||||
$grapped->got_statistics = 1;
|
||||
|
||||
@@ -156,7 +154,7 @@ class Grapper
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
$url = Grap::$options['base_url']."api/v1/event/$event_id/lineups";
|
||||
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/lineups";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
@@ -164,7 +162,7 @@ class Grapper
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder.'/lineups.json', json_encode($data));
|
||||
File::put($folder . '/lineups.json', json_encode($data));
|
||||
|
||||
$grapped->got_lineups = 1;
|
||||
|
||||
@@ -172,7 +170,7 @@ class Grapper
|
||||
* EVENT odds
|
||||
*********************************/
|
||||
|
||||
$url = Grap::$options['base_url']."api/v1/event/$event_id/odds/1/all";
|
||||
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/odds/1/all";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
@@ -180,7 +178,7 @@ class Grapper
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder.'/odds.json', json_encode($data));
|
||||
File::put($folder . '/odds.json', json_encode($data));
|
||||
|
||||
$grapped->got_odds = 1;
|
||||
|
||||
@@ -188,7 +186,7 @@ class Grapper
|
||||
* EVENT incidents
|
||||
*********************************/
|
||||
|
||||
$url = Grap::$options['base_url']."api/v1/event/$event_id/incidents";
|
||||
$url = Grap::$options['base_url'] . "api/v1/event/$event_id/incidents";
|
||||
|
||||
Sleeper::rand();
|
||||
|
||||
@@ -196,7 +194,7 @@ class Grapper
|
||||
|
||||
$data['id'] = $event_id;
|
||||
|
||||
File::put($folder.'/incidents.json', json_encode($data));
|
||||
File::put($folder . '/incidents.json', json_encode($data));
|
||||
|
||||
$grapped->got_incidents = 1;
|
||||
|
||||
@@ -206,9 +204,6 @@ class Grapper
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($debug) {
|
||||
Notice::note('END '.$tournament->tournament->name, 'p');
|
||||
}
|
||||
}
|
||||
SofaScoreTaskDay::updateOrCreate([
|
||||
'grapper_id' => (int) $task_id,
|
||||
@@ -220,9 +215,8 @@ class Grapper
|
||||
$count++;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note($count.' days done', 'bb');
|
||||
Notice::note("Grapper done, ($count)", 'bb');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ class SetStorage
|
||||
break;
|
||||
case 4:
|
||||
Grap::$storage = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d');
|
||||
Grap::$zipfile = $sofascore_data . $storage_name . '/rosa-' . Carbon::now()->format('Y-m-d') . '.zip';
|
||||
Grap::$folder = $storage_name;
|
||||
break;
|
||||
case 5:
|
||||
Grap::$storage = $sofascore_data;
|
||||
|
||||
@@ -7,7 +7,7 @@ class Sleeper
|
||||
public static function rand($langsam = false)
|
||||
{
|
||||
if ($langsam) {
|
||||
$sleep = rand(3000000, 6000000);
|
||||
$sleep = rand(3000000, 7000000);
|
||||
} else {
|
||||
$sleep = rand(100000, 150000);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ namespace App\Console\Commands\Grapper\Sofascore;
|
||||
use App\Console\Commands\Grap;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\FileType;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\ReadDir;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Utilities\Notice;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
@@ -20,10 +19,10 @@ class MakeExcel
|
||||
{
|
||||
ini_set('memory_limit', -1);
|
||||
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
$debug = Grap::$options['d'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('Make Excel folder to import: ' . Grap::$folder . "\nmaximum files in excel: " . self::$max, 'b');
|
||||
Notice::note("Make Excel\nFolder: " . Grap::$folder . "\nMax/file: " . self::$max, 'bb');
|
||||
}
|
||||
|
||||
$files = ReadDir::get_tree(Grap::$storage . '/' . Grap::$folder);
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\CurlSofa;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Strings;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Console\Commands\Grap;
|
||||
use App\Models\SofaScoreRosa;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Facades\File;
|
||||
@@ -15,11 +14,10 @@ class Rose
|
||||
{
|
||||
public static function run()
|
||||
{
|
||||
File::makeDirectory(Sofascore::$storage, 0775, true, true);
|
||||
$debug = Grap::$options['d'] ?? 0;
|
||||
$restart = Grap::$options['r'] ?? 0;
|
||||
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$restart = Nuh::$options['restart'] ?? 0;
|
||||
File::makeDirectory(Grap::$storage, 0775, true, true);
|
||||
|
||||
if ($restart) {
|
||||
SofaScoreRosa::query()->update(['grapped' => 0]);
|
||||
@@ -35,9 +33,10 @@ class Rose
|
||||
$res = SofaScoreRosa::get();
|
||||
|
||||
foreach ($res as $value) {
|
||||
$url = Nuh::$options['base_url'] . 'api/v1/team/' . $value->ss_team_id . '/players';
|
||||
$url = Grap::$options['base_url'] . 'api/v1/team/' . $value->ss_team_id . '/players';
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
$data['ss_team_id'] = $value->ss_team_id;
|
||||
$data['ss_team_name'] = $value->ss_team_name;
|
||||
|
||||
@@ -45,7 +44,7 @@ class Rose
|
||||
* add team to folder
|
||||
*********************************/
|
||||
|
||||
File::put(Sofascore::$storage . '/' . Strings::clean($value->ss_team_name) . '.json', json_encode($data));
|
||||
File::put(Grap::$storage . '/' . Strings::clean($value->ss_team_name) . '.json', json_encode($data));
|
||||
|
||||
SofaScoreRosa::where('id', $value->id)->update(['grapped' => 1]);
|
||||
|
||||
|
||||
@@ -18,6 +18,10 @@ class SendMail
|
||||
{
|
||||
$debug = Grap::$options['d'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('Send Mail', 'bb');
|
||||
}
|
||||
|
||||
$task = SofaScoreTask::where('id', $task_id)->first();
|
||||
|
||||
$files = ReadDir::get_tree(Grap::$storage);
|
||||
@@ -34,11 +38,7 @@ class SendMail
|
||||
new SofaScoreDataMail($header, $table, $sendfiles)
|
||||
);
|
||||
if ($debug) {
|
||||
Notice::note('Mail: '.$header);
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('mail send', 'g');
|
||||
Notice::note("Mail Send", 'bg');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class SendMail
|
||||
|
||||
$table = '';
|
||||
foreach ($res as $value) {
|
||||
$table .= '|'.$value->liga.'|'.$value->name.'|'.$value->starttime.'|
|
||||
$table .= '|' . $value->liga . '|' . $value->name . '|' . $value->starttime . '|
|
||||
';
|
||||
}
|
||||
|
||||
@@ -60,13 +60,13 @@ class SendMail
|
||||
$text = '## ';
|
||||
switch ($task->mode) {
|
||||
case 'daily':
|
||||
$text = $task->name.' - '.Carbon::now()->subDays(3)->format('Y-m-d');
|
||||
$text = $task->name . ' - ' . Carbon::now()->subDays(3)->format('Y-m-d');
|
||||
break;
|
||||
case 'date':
|
||||
$text = $task->name.' - '.$task->day_from;
|
||||
$text = $task->name . ' - ' . $task->day_from;
|
||||
break;
|
||||
case 'range':
|
||||
$text = $task->name.' - '.$task->day_from.' - '.$task->day_to;
|
||||
$text = $task->name . ' - ' . $task->day_from . ' - ' . $task->day_to;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@@ -15,13 +15,17 @@ class SettingsToLocal
|
||||
{
|
||||
$debug = Grap::$options['d'] ?? 0;
|
||||
|
||||
Notice::note("⚽ close all vpn");
|
||||
if ($debug) {
|
||||
Notice::note("⚽ settings to local");
|
||||
Notice::note("⚽ close all vpn");
|
||||
}
|
||||
exec('killall ssh');
|
||||
|
||||
Notice::note("⚽ open vpn");
|
||||
if ($debug) {
|
||||
Notice::note("⚽ open vpn");
|
||||
}
|
||||
exec('ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190');
|
||||
|
||||
Notice::note("⚽ settings to local");
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('SofaScoreTask', 'g');
|
||||
@@ -50,7 +54,9 @@ class SettingsToLocal
|
||||
SofaScoreTournament::insert((array) $row);
|
||||
}
|
||||
|
||||
Notice::note("⚽ close all vpn");
|
||||
if ($debug) {
|
||||
Notice::note("⚽ close all vpn");
|
||||
}
|
||||
exec('killall ssh');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user