This commit is contained in:
salam committed 2026-07-25 18:23:26 +02:00
1 parent 1890b1fcc2
commit bf48caa395
22 files changed
+502 -115

No files matched your search

+41 -3
View File
@@ -4,14 +4,16 @@ namespace App\Console\Commands\Grapper;
use App\Console\Commands\Grapper\Sofascore\Grapper; use App\Console\Commands\Grapper\Sofascore\Grapper;
use App\Console\Commands\Grapper\Sofascore\Helper\Strings; use App\Console\Commands\Grapper\Sofascore\Helper\Strings;
use App\Console\Commands\Grapper\Sofascore\Helper\ZipFolder;
use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason; use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason;
use App\Console\Commands\Grapper\Sofascore\Rose; use App\Console\Commands\Grapper\Sofascore\Rose;
use App\Console\Commands\Grapper\Sofascore\SendMail; use App\Console\Commands\Grapper\Sofascore\SendMail;
use App\Console\Commands\Grapper\Sofascore\SettingsToLocal; use App\Console\Commands\Grapper\Sofascore\SettingsToLocal;
use App\Console\Commands\Grapper\Sofascore\SqlMover;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\SofaScoreTask; use App\Models\SofaScoreTask;
use App\Utilities\Notice; use App\Utilities\Notice;
use App\Utilities\ZipFolder; use Illuminate\Support\Carbon;
ini_set('magic_quotes_runtime', false); ini_set('magic_quotes_runtime', false);
@@ -19,6 +21,10 @@ class Sofascore
{ {
public static string $storage; public static string $storage;
public static string $archive_name;
public static string $useragent;
public static function switch() public static function switch()
{ {
$function = Nuh::$options['fun']; $function = Nuh::$options['fun'];
@@ -35,23 +41,32 @@ class Sofascore
case 3: case 3:
self::setStorage(); self::setStorage();
Grapper::load(); Grapper::load();
break; break;
case 4: case 4:
self::setStorage(); self::setStorage();
ZipFolder::create(self::$storage);
ZipFolder::create();
break; break;
case 5: case 5:
self::setStorage(); self::setStorage();
SendMail::run(); SendMail::run();
break; break;
case 6: case 6:
self::setStorage();
Rose::run(); Rose::run();
break; break;
case 7:
SqlMover::run();
break;
default: default:
Notice::note('id not valid', 'br', 1); Notice::note('id not valid', 'br', 1);
} }
@@ -61,6 +76,29 @@ class Sofascore
{ {
$task = Nuh::$options['task']; $task = Nuh::$options['task'];
self::$storage = storage_path('sofascore_data') . '/' . Strings::clean(SofaScoreTask::where('id', $task)->value('name')); self::$storage = storage_path('sofascore_data') . '/';
self::$useragent = 4;
$storage_name = Strings::clean(SofaScoreTask::where('id', $task)->value('name')) . '/';
switch ($task) {
case 1:
self::$archive_name = Carbon::now()->subDays(3)->format('Y-m-d') . '.zip';
self::$storage .= $storage_name;
break;
case 2:
case 3:
self::$archive_name = $storage_name . '.zip';
self::$storage .= $storage_name;
break;
case 4:
self::$archive_name = 'rosa-' . Carbon::now()->format('Y-m-d') . '.zip';
self::$storage .= $storage_name . 'rosa-' . Carbon::now()->format('Y-m-d');
break;
default:
self::$archive_name = 'archive.zip';
break;
}
} }
} }
@@ -21,7 +21,7 @@ class Grapper
{ {
$debug = Nuh::$options['d'] ?? 0; $debug = Nuh::$options['d'] ?? 0;
$force = Nuh::$options['f'] ?? 0; $force = Nuh::$options['ff'] ?? 0;
$task_id = Nuh::$options['task'] ?? 0; $task_id = Nuh::$options['task'] ?? 0;
@@ -29,26 +29,34 @@ class Grapper
$days = LoadDays::load(); $days = LoadDays::load();
$count = 0;
$active_tournaments = SofaScoreTaskTournament::with('tournament')->where('sofa_score_task_id', $task_id)->where('disabled', false)->get(); $active_tournaments = SofaScoreTaskTournament::with('tournament')->where('sofa_score_task_id', $task_id)->where('disabled', false)->get();
/**
* daily restart always
*/
if ($task_id == 1) SofaScoreEventGrapped::where('grapper_id', $task_id)->delete();
/** /**
* empty grapping folder * empty grapping folder
* empty mailing text * empty mailing text
*/ */
if ($restart) { if ($restart) {
File::cleanDirectory(Sofascore::$storage);
SofaScoreEventGrapped::where('grapper_id', $task_id)->delete(); SofaScoreEventGrapped::where('grapper_id', $task_id)->delete();
foreach ($days as $d) {
SofaScoreTaskDay::where('grapper_id', (int) $task_id)
->where('day', $d['day'])
->update(['done' => 0]);
}
if ($debug) { if ($debug) {
Notice::note('Restart grapper', 'br'); Notice::note('reset grapper', 'br', 1);
Notice::note('Cleand task directory', 'b');
Notice::note('Flush table SofaScoreEventGrapped for task', 'b');
} }
} else { } else {
if ($debug) { if ($debug) {
Notice::note('Continuing grapper', 'bg'); Notice::note('continuing grapper', 'bg');
} }
} }
@@ -61,7 +69,7 @@ class Grapper
$day = $d['day']; $day = $d['day'];
if ($debug) { if ($debug) {
Notice::note('Start ' . $tournament->tournament->name, 'b'); Notice::note('START ' . $tournament->tournament->name, 'p');
} }
$res = SofaScoreDayTournament::whereDate('day', '=', $day)->where('tournament_id', $tournament->sofa_score_tournament_id)->first(); $res = SofaScoreDayTournament::whereDate('day', '=', $day)->where('tournament_id', $tournament->sofa_score_tournament_id)->first();
@@ -86,6 +94,8 @@ class Grapper
foreach ($data['events'] as $event) { foreach ($data['events'] as $event) {
Sofascore::$useragent = rand(1, 6);
if (!$force && SofaScoreEventGrapped::where('id', (int) $event['id'])->exists()) { if (!$force && SofaScoreEventGrapped::where('id', (int) $event['id'])->exists()) {
if ($debug) { 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');
@@ -114,7 +124,7 @@ class Grapper
$grapped->url = $url; $grapped->url = $url;
$grapped->starttime = $starttime->toDateTimeString(); $grapped->starttime = $starttime->toDateTimeString();
$folder = Sofascore::$storage . '/' . $day . '/' . $event['tournament']['slug'] . '/' . $event['slug']; $folder = Sofascore::$storage . '/' . $day . '/' . $day . '-' . $event['tournament']['slug'] . '/' . $event['slug'];
File::makeDirectory($folder, 0775, true, true); File::makeDirectory($folder, 0775, true, true);
@@ -219,7 +229,14 @@ class Grapper
'done' => 1, 'done' => 1,
]); ]);
Notice::note('DAY DONE', 'br', 1); $count++;
Notice::note($count . ' DAYS DONE', 'bb');
// if ($count > 20)
// Notice::note($count . ' DAYS DONE', 'br', 1);
// else
// Notice::note($count . ' DAYS DONE', 'bb');
} }
} }
} }
@@ -2,6 +2,7 @@
namespace App\Console\Commands\Grapper\Sofascore\Helper; namespace App\Console\Commands\Grapper\Sofascore\Helper;
use App\Console\Commands\Grapper\Sofascore;
use App\Utilities\Notice; use App\Utilities\Notice;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
@@ -32,8 +33,20 @@ class CurlSofa
return json_decode($data, true); return json_decode($data, true);
} }
$useragents = [];
$useragents[1] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15';
$useragents[2] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15';
$useragents[3] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36';
$useragents[4] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15';
$useragents[5] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0';
$useragents[6] = 'Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36';
// if ($debug) {
// Notice::note($useragents[Sofascore::$useragent], 'b');
// }
$headers = [ $headers = [
'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0', 'User-Agent: ' . $useragents[Sofascore::$useragent],
'Accept: */*', 'Accept: */*',
'Accept-Language: de,en-US;q=0.7,en;q=0.3', 'Accept-Language: de,en-US;q=0.7,en;q=0.3',
'Accept-Encoding: gzip, deflate, br, zstd', 'Accept-Encoding: gzip, deflate, br, zstd',
@@ -94,7 +94,7 @@ class LoadDays
} }
if (! $dates) { if (! $dates) {
Notice::note(__FILE__ . PHP_EOL . 'no dates', 'r', 1); Notice::note('NO DATES OR ALL GRAPPED', 'br', 1);
} }
// remove when element in array is double (day and slug) // remove when element in array is double (day and slug)
@@ -1,30 +1,31 @@
<?php <?php
namespace App\Utilities; namespace App\Console\Commands\Grapper\Sofascore\Helper;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
use RecursiveIteratorIterator; use RecursiveIteratorIterator;
use ZipArchive; use ZipArchive;
use App\Console\Commands\Grapper\Sofascore;
class ZipFolder class ZipFolder
{ {
public static function create(string $path) public static function create()
{ {
$zipFilePath = $path . '/archive.zip'; $zipFilePath = Sofascore::$storage . Sofascore::$archive_name;
$zip = new ZipArchive(); $zip = new ZipArchive();
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) { if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
if (is_dir($path)) { if (is_dir(Sofascore::$storage)) {
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(Sofascore::$storage));
foreach ($files as $file) { foreach ($files as $file) {
if (!$file->isDir()) { if (!$file->isDir()) {
$filePath = $file->getRealPath(); $filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($path) + 1); $relativePath = substr($filePath, strlen(Sofascore::$storage) + 1);
$zip->addFile($filePath, $relativePath); $zip->addFile($filePath, $relativePath);
} }
} }
+35 -10
View File
@@ -4,31 +4,56 @@ namespace App\Console\Commands\Grapper\Sofascore;
use 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\CurlSofa;
use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper; 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\Nuh;
use App\Models\SofaScoreDayTournament; use App\Models\SofaScoreRosa;
use App\Models\SofaScoreEventGrapped;
use App\Models\SofaScoreTaskDay;
use App\Models\SofaScoreTaskTournament;
use App\Models\SofaScoreTournament;
use App\Utilities\Notice; use App\Utilities\Notice;
use Illuminate\Support\Carbon; use Carbon\Carbon;
use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\File;
class Rose class Rose
{ {
public static function run() public static function run()
{ {
File::makeDirectory(Sofascore::$storage, 0775, true, true);
$debug = Nuh::$options['d'] ?? 0; $debug = Nuh::$options['d'] ?? 0;
$task_id = Nuh::$options['task'] ?? 0; $restart = Nuh::$options['restart'] ?? 0;
$url = Nuh::$options['base_url'] . "api/v1/team/4937/players"; if ($restart) {
SofaScoreRosa::query()->update(['grapped' => 0]);
if ($debug) {
Notice::note('Restart rosa grapper', 'b');
}
} else {
if ($debug) {
Notice::note('continuing grapping', 'bg');
}
}
$res = SofaScoreRosa::where('id', '>', 441)->get();
foreach ($res as $value) {
$url = Nuh::$options['base_url'] . 'api/v1/team/' . $value->ssteam_id . '/players';
$data = CurlSofa::load($url); $data = CurlSofa::load($url);
dd($data); /*********************************
* add team to folder
*********************************/
File::put(Sofascore::$storage . '/' . Strings::clean($value->ssteam_name) . '.json', json_encode($data));
SofaScoreRosa::where('id', $value->id)->update(['grapped' => 1]);
if (rand(0, 1))
Sleeper::rand(1);
else
Sleeper::rand(0);
}
} }
} }
@@ -2,14 +2,15 @@
namespace App\Console\Commands\Grapper\Sofascore; namespace App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Mail\SofaScoreDataMail; use App\Mail\SofaScoreDataMail;
use App\Models\SofaScoreEventGrapped; use App\Models\SofaScoreEventGrapped;
use App\Utilities\Notice; use App\Utilities\Notice;
use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Mail;
use App\Console\Commands\Grapper\Sofascore;
use App\Models\SofaScoreTask;
use Carbon\Carbon;
class SendMail class SendMail
{ {
@@ -17,26 +18,29 @@ class SendMail
{ {
$debug = Nuh::$options['d'] ?? 0; $debug = Nuh::$options['d'] ?? 0;
$days = LoadDays::load(); $task_id = Nuh::$options['task'] ?? 0;
foreach ($days as $d) { $task = SofaScoreTask::where('id', $task_id)->first();
$day = $d['day']; $zip_file = Sofascore::$storage . Sofascore::$archive_name;
$message = self::createMailText($day); $header = self::createHeader($task);
$zip_file = Sofascore::$storage . '/' . $day . '.zip'; $message = self::createMessage($task);
if (File::exists($zip_file)) { if (File::exists($zip_file)) {
Mail::to('hermann.telser@gmail.com') Mail::to('hermann.telser@gmail.com')
->cc('ubaldo.perrucci@gmail.com') // ->cc('ubaldo.perrucci@gmail.com')
->send( ->send(
new SofaScoreDataMail($day, $message, $zip_file) new SofaScoreDataMail($header, $message)
); );
if ($debug) { if ($debug) {
Notice::note('Mail send' . $day); Notice::note('Mail: ' . $header);
} }
} else {
if ($debug) {
Notice::note('zip not found ' . $zip_file, 'r', 1);
} }
} }
@@ -45,15 +49,41 @@ class SendMail
} }
} }
public static function createMailText(string $day) public static function createMessage(SofaScoreTask $task)
{ {
$res = SofaScoreEventGrapped::where('day', $day)->get(); $res = SofaScoreEventGrapped::where('grapper_id', $task->id)->get();
$text = "## Mail Content $day
"; $text = '
';
foreach ($res as $value) { foreach ($res as $value) {
$text .= "### $value->liga * $value->name * $value->starttime $text .= $value->liga . ' - ' . $value->name . ' - ' . $value->starttime;
"; $text .= '
';
} }
return $text; return $text;
} }
public static function createHeader(SofaScoreTask $task)
{
$text = "## ";
switch ($task->mode) {
case 'daily':
$text = $task->name . ' - ' . Carbon::now()->subDays(3)->format('Y-m-d');
break;
case 'date':
$text = $task->name . ' - ' . $task->day_from;
break;
case 'range':
$text = $task->name . ' - ' . $task->day_from . ' - ' . $task->day_to;
break;
default:
$text = $task->name;
break;
}
return $text;
}
} }
@@ -19,18 +19,27 @@ class SettingsToLocal
Notice::note('Settings To Local', 'bb'); Notice::note('Settings To Local', 'bb');
} }
if ($debug) {
Notice::note('SofaScoreTask', 'g');
}
SofaScoreTask::truncate(); SofaScoreTask::truncate();
$rows = DB::connection('remote_mariadb')->table('sofa_score_tasks')->get(); $rows = DB::connection('remote_mariadb')->table('sofa_score_tasks')->get();
foreach ($rows as $row) { foreach ($rows as $row) {
SofaScoreTask::insert((array) $row); SofaScoreTask::insert((array) $row);
} }
if ($debug) {
Notice::note('SofaScoreTaskTournament', 'g');
}
SofaScoreTaskTournament::truncate(); SofaScoreTaskTournament::truncate();
$rows = DB::connection('remote_mariadb')->table('sofa_score_task_tournaments')->get(); $rows = DB::connection('remote_mariadb')->table('sofa_score_task_tournaments')->get();
foreach ($rows as $row) { foreach ($rows as $row) {
SofaScoreTaskTournament::insert((array) $row); SofaScoreTaskTournament::insert((array) $row);
} }
if ($debug) {
Notice::note('SofaScoreRosa', 'g');
}
SofaScoreRosa::truncate(); SofaScoreRosa::truncate();
$rows = DB::connection('remote_mariadb')->table('sofa_score_rosas')->get(); $rows = DB::connection('remote_mariadb')->table('sofa_score_rosas')->get();
foreach ($rows as $row) { foreach ($rows as $row) {
@@ -2,21 +2,27 @@
namespace App\Console\Commands\Grapper\Sofascore; namespace App\Console\Commands\Grapper\Sofascore;
use App\Models\SofaScoreTaskTournament; use App\Models\StatistikoEvent;
use App\Models\SofaScoreTournament;
use App\Utilities\Notice; use App\Utilities\Notice;
class SqlMover class SqlMover
{ {
public static function run() public static function run()
{ {
// $ligas = [649, 242, 20, 40, 325, 41];
$ligas = [5, 9, 19, 26, 13, 99];
$res = SofaScoreTaskTournament::get(); Notice::note('SqlMover', 'b');
foreach ($res as $value) { foreach ($ligas as $liga_id) {
$res2 = SofaScoreTournament::where('tournament_id', $value->sofa_score_tournament_id)->first();
SofaScoreTaskTournament::where('id', $value->id)->update(['sofa_score_category_id' => $res2->sofa_score_category_id]); $res = StatistikoEvent::where('league_id', $liga_id)->pluck('match_id');
dd($res);
foreach ($res as $match_id) {
dd($match_id);
}
} }
Notice::note('done', 'bb', 1); Notice::note('done', 'bb', 1);
@@ -25,7 +25,9 @@ class Groups
foreach ($kontos as $konto => $authentication) { foreach ($kontos as $konto => $authentication) {
$url = 'https://xml2.txodds.com/feed/groups.php?'.$authentication.'&sid='.implode(',', $years); $url = 'https://xml2.txodds.com/feed/groups.php?' . $authentication . '&sid=' . implode(',', $years);
// https://xml2.txodds.com/feed/groups.php?ident=betaid1&passwd=Dy59vpRC&sid=25
// <group> // <group>
// <id>181996</id> // <id>181996</id>
+2 -1
View File
@@ -23,7 +23,7 @@ class Nuh extends Command
public static $id = 0; public static $id = 0;
protected $signature = 'nuh {process=help} {--truncate} {--id=0} {--fun=} {--task=0} {--restart=0} {--gid=} {--p} {--d} {--x} {--t} {--y} {--m} {--l} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e} {--z}'; protected $signature = 'nuh {process=help} {--truncate} {--id=0} {--fun=} {--ff} {--task=0} {--restart=0} {--gid=} {--p} {--d} {--x} {--t} {--y} {--m} {--l} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e} {--z}';
public function handle() public function handle()
{ {
@@ -64,6 +64,7 @@ class Nuh extends Command
$txt .= '--d debug' . PHP_EOL; $txt .= '--d debug' . PHP_EOL;
$txt .= '--e echo client data' . PHP_EOL; $txt .= '--e echo client data' . PHP_EOL;
$txt .= '--f force (what ever in script)' . PHP_EOL; $txt .= '--f force (what ever in script)' . PHP_EOL;
$txt .= '--ff force grapping (sofascore)' . PHP_EOL;
$txt .= '--g by minor groups (tx)' . PHP_EOL; $txt .= '--g by minor groups (tx)' . PHP_EOL;
$txt .= '--t load today' . PHP_EOL; $txt .= '--t load today' . PHP_EOL;
$txt .= '--m mail it' . PHP_EOL; $txt .= '--m mail it' . PHP_EOL;
@@ -8,7 +8,6 @@ use Filament\Actions\Action;
use Filament\Actions\BulkAction; use Filament\Actions\BulkAction;
use Filament\Actions\BulkActionGroup; use Filament\Actions\BulkActionGroup;
use Filament\Actions\CreateAction; use Filament\Actions\CreateAction;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction; use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\ToggleColumn; use Filament\Tables\Columns\ToggleColumn;
@@ -22,6 +21,7 @@ class SofaScoreRosasTable
public static function configure(Table $table): Table public static function configure(Table $table): Table
{ {
return $table return $table
->description('The squad for the team selected will be send next day via mail. The selection will be unset after sending.')
->columns([ ->columns([
TextColumn::make('ssteam_id')->label('Id')->badge()->width('1rem'), TextColumn::make('ssteam_id')->label('Id')->badge()->width('1rem'),
TextColumn::make('country.name')->label('Country'), TextColumn::make('country.name')->label('Country'),
@@ -20,6 +20,7 @@ use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\ToggleColumn; use Filament\Tables\Columns\ToggleColumn;
use Filament\Tables\Enums\FiltersLayout; use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\SelectFilter; use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@@ -71,6 +72,7 @@ class SofaScoreTaskTournamentsRelationManager extends RelationManager
TextColumn::make('category.name') TextColumn::make('category.name')
->label('Category') ->label('Category')
->searchable(), ->searchable(),
TextColumn::make('tournament.tournament_id'),
TextColumn::make('tournament.name') TextColumn::make('tournament.name')
->weight(FontWeight::Bold) ->weight(FontWeight::Bold)
->searchable(), ->searchable(),
@@ -88,7 +90,8 @@ class SofaScoreTaskTournamentsRelationManager extends RelationManager
->pluck('sofa_score_category_id') ->pluck('sofa_score_category_id')
->toArray(); ->toArray();
return SofaScoreCategory::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id'); return SofaScoreCategory::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
}) }),
TernaryFilter::make('disabled'),
], layout: FiltersLayout::AboveContent) ], layout: FiltersLayout::AboveContent)
->deferFilters(false) ->deferFilters(false)
->headerActions([ ->headerActions([
+7 -5
View File
@@ -8,6 +8,7 @@ use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content; use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope; use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use App\Console\Commands\Grapper\Sofascore;
class SofaScoreDataMail extends Mailable class SofaScoreDataMail extends Mailable
{ {
@@ -16,11 +17,12 @@ class SofaScoreDataMail extends Mailable
/** /**
* Create a new message instance. * Create a new message instance.
*/ */
public function __construct(string $day, string $message, string $zip_file) public function __construct(string $header, string $message)
{ {
$this->day = $day; $this->header = $header;
$this->message = $message; $this->message = $message;
$this->zip_file = $zip_file; $this->archive_name = Sofascore::$archive_name;
$this->zip_file = Sofascore::$storage . Sofascore::$archive_name;
} }
/** /**
@@ -29,7 +31,7 @@ class SofaScoreDataMail extends Mailable
public function envelope(): Envelope public function envelope(): Envelope
{ {
return new Envelope( return new Envelope(
subject: 'Sofa Score ' . $this->day, subject: $this->header,
); );
} }
@@ -55,7 +57,7 @@ class SofaScoreDataMail extends Mailable
{ {
return [ return [
Attachment::fromPath($this->zip_file) Attachment::fromPath($this->zip_file)
->as('sofa archive ' . $this->day . '.zip') ->as($this->archive_name)
->withMime('application/x-zip-compressed') ->withMime('application/x-zip-compressed')
]; ];
} }
+16 -7
View File
@@ -4,18 +4,27 @@ namespace App\Utilities;
class Notice class Notice
{ {
// note /**
* \e[1;30m Black
* \e[1;31m Red
* \e[1;32m Green
* \e[1;33m Yellow
* \e[1;34m Blue
* \e[1;35m Purple
* \e[1;36m Cyan
* \e[1;37m White
*/
public static function db($message, $exit = false) public static function db($message, $exit = false)
{ {
echo "\e[0;35m"; echo "\e[0;35m";
echo PHP_EOL.'-----------------------------------------------------------'.PHP_EOL; echo PHP_EOL . '-----------------------------------------------------------' . PHP_EOL;
if (is_array($message)) { if (is_array($message)) {
print_r($message); print_r($message);
} else { } else {
echo $message.PHP_EOL; echo $message . PHP_EOL;
} }
echo '-----------------------------------------------------------'.PHP_EOL; echo '-----------------------------------------------------------' . PHP_EOL;
echo "\e[0;39m"; echo "\e[0;39m";
if ($exit) { if ($exit) {
exit(); exit();
@@ -72,13 +81,13 @@ class Notice
break; break;
} }
echo PHP_EOL.'-----------------------------------------------------------'.PHP_EOL; echo PHP_EOL . '-----------------------------------------------------------' . PHP_EOL;
if (is_array($message)) { if (is_array($message)) {
print_r($message); print_r($message);
} else { } else {
echo $message.PHP_EOL; echo $message . PHP_EOL;
} }
echo '-----------------------------------------------------------'.PHP_EOL; echo '-----------------------------------------------------------' . PHP_EOL;
echo "\e[0;39m"; echo "\e[0;39m";
if ($exit) { if ($exit) {
exit(); exit();
@@ -17,6 +17,7 @@ return new class extends Migration
$table->integer('ssteam_id'); $table->integer('ssteam_id');
$table->string('ssteam_name'); $table->string('ssteam_name');
$table->boolean('is_active')->default(false); $table->boolean('is_active')->default(false);
$table->boolean('grapped')->default(false);
$table->timestamps(); $table->timestamps();
}); });
} }
Executable
+138
View File
@@ -0,0 +1,138 @@
case "$1" in
"1")
echo ""
echo "\033[1;32m";
echo "--------------------------"
echo "⚽ Daily Task: 1"
echo "--------------------------"
echo "\033[0;0m";
echo "\n--------------------------"
echo "5 sec to stop"
echo "--------------------------"
sleep 5
echo "\n⚽ Grapper"
php artisan nuh --d --f --ff 67 --fun=3 --task=1
echo "\n⚽ CreateZip"
php artisan nuh --d --f 67 --fun=4 --task=1
echo "\n⚽ SendMail"
php artisan nuh --d --f 67 --fun=5 --task=1
echo "\n😎 task done :)"
echo ""
;;
"2")
echo ""
echo "\033[1;34m";
echo "--------------------------"
echo "⚽ Day: 2"
echo "--------------------------"
echo "\033[0;0m";
echo "not implemented yet"
;;
"3")
echo ""
echo "\033[1;33m";
echo "--------------------------"
echo "⚽ Range Task: 3"
echo "--------------------------"
echo "\033[0;0m";
echo "\n--------------------------"
echo "only grapping but the process can be restarted"
echo "To do:"
echo "on ending make Zip"
echo "upload to Cloud"
echo "send Mail to Ubaldo"
echo "--------------------------\n"
echo "\n--------------------------"
echo "5 sec to stop"
echo "restart with second param: 1"
echo "--------------------------"
sleep 5
echo "\n⚽ Grapper"
php artisan nuh --d --f --ff 67 --fun=3 --task=3 --restart=$2
# echo "\n⚽ CreateZip"
# php artisan nuh --d --f 67 --fun=4 --task=3
# echo "\n⚽ SendMail"
# php artisan nuh --d --f 67 --fun=5 --task=3
echo "\n😎 task done :)"
echo ""
;;
"4")
echo ""
echo "\033[1;35m";
echo "--------------------------"
echo "⚽ Rosa Task: 4"
echo "--------------------------"
echo "\033[0;0m";
echo "\n--------------------------"
echo "5 sec to stop"
echo "restart with second param: 1"
echo "--------------------------"
sleep 5
echo "\n⚽ Rosa"
php artisan nuh --d --f 67 --fun=6 --task=4 --restart=$2
echo "\n😎 task done :)"
echo ""
;;
"5")
echo ""
echo "\033[1;36m";
echo "--------------------------"
echo "⚽ Copy Settings: 5"
echo "--------------------------"
echo "\033[0;0m";
echo "\n--------------------------"
echo "5 sec to stop"
echo "--------------------------"
sleep 5
echo "\n⚽ close all vpn"
killall ssh
echo "\n⚽ open vpn"
ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190
echo "\n⚽ Settings To Local"
php artisan nuh --d --f 67 --fun=2 --task=0
echo "\n⚽ close vpn"
killall ssh
echo "\n😎 task done :)"
echo ""
;;
*)
echo ""
echo "\033[1;30m";
echo "--------------------------"
echo " Grapper Options"
echo "--------------------------"
echo "\033[1;32m";
echo "⚽ Daily\tTask: 1"
echo "\033[1;34m";
echo "⚽ Day\t\tTask: 2"
echo "\033[1;33m";
echo "⚽ Range\tTask: 3"
echo "\033[1;35m";
echo "⚽ Rosa\t\tTask: 4"
echo "\033[1;36m";
echo "⚽ Settings\tTask: 5"
echo "\033[0;0m";
echo "--------------------------"
;;
esac
+60
View File
@@ -0,0 +1,60 @@
case "$1" in
"1")
echo ""
echo "\033[1;32m";
echo "--------------------------"
echo "⚽ Daily Task: 1"
echo "--------------------------"
echo "\033[0;0m";
echo "\n--------------------------"
echo "5 sec to stop"
echo "--------------------------"
sleep 5
echo "\n⚽ Grapper"
php artisan nuh --d --f --ff 67 --fun=3 --task=1
echo "\n⚽ CreateZip"
php artisan nuh --d --f 67 --fun=4 --task=1
echo "\n⚽ SendMail"
php artisan nuh --d --f 67 --fun=5 --task=1
echo "\n😎 task done :)"
echo ""
;;
"2")
echo ""
echo "\033[1;34m";
echo "--------------------------"
echo "⚽ Range Task: 3"
echo "--------------------------"
echo "\033[0;0m";
echo "\n--------------------------"
echo "To do:"
echo "on ending make Zip"
echo "upload to Cloud"
echo "send Mail to Ubaldo"
echo "--------------------------\n"
echo "\n--------------------------"
echo "5 sec to stop"
echo "restart with: 1"
echo "--------------------------"
sleep 5
echo "\n⚽ Grapper"
# php artisan nuh --d --f --ff 67 --fun=3 --task=3 --restart=$1
echo "\n⚽ CreateZip"
# php artisan nuh --d --f 67 --fun=4 --task=3
echo "\n⚽ SendMail"
# php artisan nuh --d --f 67 --fun=5 --task=3
echo "\n😎 task done :)"
echo ""
;;
-46
View File
@@ -1,46 +0,0 @@
case "$1" in
''|*[!0-9]*)
echo ""
echo "--------------------------"
echo "GRAPPER SOFASCORE"
echo "--------------------------"
echo "parameter ID"
echo "--task = sofa_score_tasks_id"
echo "--restart = [0|1]"
echo "--------------------------"
echo "--fun = Sofascore.php switch() "
echo "SELECT liga, name, starttime FROM sofa_score_event_grappeds WHERE grapper_id = 1;"
echo ""
exit 1
;;
*)
# AUTO GRAPPER SOFASCORE (debug)
echo "\n⚽ sofa_score_task $1"
# echo "\n⚽ close all vpn"
# killall ssh
# echo "\n⚽ open vpn"
# ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190
# echo "\n⚽ Settings To Local"
# php artisan nuh --d --f 67 --fun=2 --task=$1
# echo "\n⚽ close vpn"
# killall ssh
echo "\n⚽ Grapper"
php artisan nuh --d --f 67 --fun=3 --task=$1 --restart=$2
# echo "\n⚽ CreateZip"
# php artisan nuh --d --f 67 --fun=4 --task=$1
# echo "\n⚽ SendMail"
# php artisan nuh --d --f 67 --fun=5 --task=$1
echo "\n😎 done :)"
;;
esac
+34
View File
@@ -0,0 +1,34 @@
echo ""
echo "\033[1;34m";
echo "--------------------------"
echo "⚽ Range Task: 3"
echo "--------------------------"
echo "\033[0;0m";
echo "\n--------------------------"
echo "To do:"
echo "on ending make Zip"
echo "upload to Cloud"
echo "send Mail to Ubaldo"
echo "--------------------------\n"
echo "\n--------------------------"
echo "5 sec to stop"
echo "restart with: 1"
echo "--------------------------"
sleep 5
echo "\n⚽ Grapper"
# php artisan nuh --d --f --ff 67 --fun=3 --task=3 --restart=$1
echo "\n⚽ CreateZip"
# php artisan nuh --d --f 67 --fun=4 --task=3
echo "\n⚽ SendMail"
# php artisan nuh --d --f 67 --fun=5 --task=3
echo "\n😎 task done :)"
echo ""
+18
View File
@@ -0,0 +1,18 @@
echo ""
echo "\033[1;35m";
echo "--------------------------"
echo "⚽ Rosa Task: 4"
echo "--------------------------"
echo "\033[0;0m";
echo "\n--------------------------"
echo "5 sec to stop"
echo "restart with: 1"
echo "--------------------------"
sleep 5
echo "\n⚽ Rosa"
php artisan nuh --d --f 67 --fun=6 --task=4 --restart=$1
echo "\n😎 task done :)"
echo ""
+26
View File
@@ -0,0 +1,26 @@
echo ""
echo "\033[1;36m";
echo "--------------------------"
echo "⚽ Copy settings"
echo "--------------------------"
echo "\033[0;0m";
echo "\n--------------------------"
echo "5 sec to stop"
echo "--------------------------"
sleep 5
echo "\n⚽ close all vpn"
killall ssh
echo "\n⚽ open vpn"
ssh -f -N -L 13306:127.0.0.1:3306 -p 58371 root@162.55.242.190
echo "\n⚽ Settings To Local"
php artisan nuh --d --f 67 --fun=2 --task=0
echo "\n⚽ close vpn"
killall ssh
echo "\n😎 task done :)"
echo ""