wip
This commit is contained in:
1 parent
acf1b78c47
commit
03b3d47151
7 files changed
+129
-34
No files matched your search
+4
@@ -38,6 +38,10 @@ class SofaScoreTournamentsTable
|
|||||||
->icon(fn ($record) => $record->sofascore_category->flag)
|
->icon(fn ($record) => $record->sofascore_category->flag)
|
||||||
->sortable(),
|
->sortable(),
|
||||||
TextColumn::make('name')->searchable()->sortable(),
|
TextColumn::make('name')->searchable()->sortable(),
|
||||||
|
// ToggleColumn::make('major')
|
||||||
|
// ->tooltip('Grapping Rose')
|
||||||
|
// ->alignCenter()
|
||||||
|
// ->sortable(),
|
||||||
ToggleColumn::make('enabled')
|
ToggleColumn::make('enabled')
|
||||||
->label('In Statistiko')
|
->label('In Statistiko')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ class SofaScoreRosaTournament extends Model
|
|||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'ss_team_id',
|
'ss_team_id',
|
||||||
'ss_tournament_id',
|
'ss_tournament_id',
|
||||||
|
'major',
|
||||||
'grapped',
|
'grapped',
|
||||||
'disabled',
|
'disabled',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ trait GrappingSofascore
|
|||||||
use GrappingEvent;
|
use GrappingEvent;
|
||||||
use GrappingHelper;
|
use GrappingHelper;
|
||||||
use GrappingMail;
|
use GrappingMail;
|
||||||
|
use GrappingTeams;
|
||||||
use GrappingToExcel;
|
use GrappingToExcel;
|
||||||
use GrappingTournaments;
|
use GrappingTournaments;
|
||||||
|
|
||||||
@@ -82,6 +83,10 @@ trait GrappingSofascore
|
|||||||
$this->range_grapper_nobreak();
|
$this->range_grapper_nobreak();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'rose':
|
||||||
|
$this->team_rose();
|
||||||
|
break;
|
||||||
|
|
||||||
case 'settings':
|
case 'settings':
|
||||||
$this->settings_to_local();
|
$this->settings_to_local();
|
||||||
break;
|
break;
|
||||||
@@ -299,7 +304,7 @@ trait GrappingSofascore
|
|||||||
options: [
|
options: [
|
||||||
'daily' => 'Select day back',
|
'daily' => 'Select day back',
|
||||||
'range' => 'Range',
|
'range' => 'Range',
|
||||||
'rose' => 'Rose',
|
'rose' => 'Rose Teams',
|
||||||
'player' => 'Player',
|
'player' => 'Player',
|
||||||
'settings' => 'Settings',
|
'settings' => 'Settings',
|
||||||
'excel' => 'Excel',
|
'excel' => 'Excel',
|
||||||
|
|||||||
@@ -0,0 +1,102 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Traits\Sofascore;
|
||||||
|
|
||||||
|
use App\Console\Commands\Grapper\Sofascore\Helper\Strings;
|
||||||
|
use App\Models\SofaScoreRosa;
|
||||||
|
use App\Models\SofaScoreRosaTournament;
|
||||||
|
use App\Models\SofaScoreTournament;
|
||||||
|
use App\Services\CloudflareSolverService;
|
||||||
|
use App\Utilities\Notice;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
|
||||||
|
use function Laravel\Prompts\select;
|
||||||
|
|
||||||
|
trait GrappingTeams
|
||||||
|
{
|
||||||
|
protected int $max = 2000;
|
||||||
|
|
||||||
|
public function team_rose()
|
||||||
|
{
|
||||||
|
// LaLiga 8
|
||||||
|
// Ita A 23
|
||||||
|
// Ita B 53
|
||||||
|
// Eng Prem 17
|
||||||
|
// Bundesliga 35
|
||||||
|
// FRA Ligue 1 34
|
||||||
|
// ENG1, ESP1, ITA1, ITA2, FRA1 e GER1
|
||||||
|
$major = [8, 17, 23, 34, 35, 53];
|
||||||
|
|
||||||
|
$what = $this->select_what_to_grap();
|
||||||
|
|
||||||
|
if ($this->restart) {
|
||||||
|
SofaScoreRosa::query()->update(['grapped' => 0]);
|
||||||
|
$this->clear_folder($this->data_dir, 'all');
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($what) {
|
||||||
|
case 'major':
|
||||||
|
$tournaments = SofaScoreTournament::where('enabled', 1)->whereIn('tournament_id', $major)->pluck('tournament_id')->toArray();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
$tournaments = SofaScoreTournament::where('enabled', 1)->whereNotIn('tournament_id', $major)->pluck('tournament_id')->toArray();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmp = SofaScoreRosaTournament::whereIn('ss_tournament_id', $tournaments)->pluck('ss_team_id')->toArray();
|
||||||
|
|
||||||
|
$teams = SofaScoreRosa::where('is_active', 1)->whereIn('ss_team_id', $tmp)->where('grapped', 0)->get();
|
||||||
|
|
||||||
|
$count = \count($teams);
|
||||||
|
|
||||||
|
$cloudflareService = new CloudflareSolverService;
|
||||||
|
|
||||||
|
foreach ($teams as $key => $value) {
|
||||||
|
|
||||||
|
if ($this->debug) {
|
||||||
|
$key++;
|
||||||
|
echo "\n$key/$count\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $this->base_url."api/v1/team/$value->ss_team_id/players";
|
||||||
|
|
||||||
|
if ($this->debug) {
|
||||||
|
Notice::note($url, 'b');
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $cloudflareService->getJsonFromUrl($url);
|
||||||
|
|
||||||
|
$data['ss_team_id'] = $value->ss_team_id;
|
||||||
|
|
||||||
|
$data['ss_team_name'] = $value->ss_team_name;
|
||||||
|
|
||||||
|
/*********************************
|
||||||
|
* add team to folder
|
||||||
|
*********************************/
|
||||||
|
|
||||||
|
File::put($this->data_dir.'/'.Strings::clean($value->ss_team_name).'.json', json_encode($data));
|
||||||
|
|
||||||
|
SofaScoreRosa::where('id', $value->id)->update(['grapped' => 1]);
|
||||||
|
|
||||||
|
$this->sleep();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->import_to_excel("rose_$what");
|
||||||
|
|
||||||
|
if ($this->debug) {
|
||||||
|
Notice::note('DONE', 'bb');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function select_what_to_grap(): string
|
||||||
|
{
|
||||||
|
return select(
|
||||||
|
label: 'What teams should be grapped?',
|
||||||
|
options: [
|
||||||
|
'major' => 'Major Leagues',
|
||||||
|
'others' => 'Others Leagues',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,9 +4,10 @@ namespace App\Traits\Sofascore;
|
|||||||
|
|
||||||
use App\Models\SofaScoreTask;
|
use App\Models\SofaScoreTask;
|
||||||
use App\Utilities\Notice;
|
use App\Utilities\Notice;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
use Illuminate\Support\Facades\File;
|
|
||||||
|
|
||||||
trait GrappingToExcel
|
trait GrappingToExcel
|
||||||
{
|
{
|
||||||
@@ -26,15 +27,23 @@ trait GrappingToExcel
|
|||||||
case 'daily':
|
case 'daily':
|
||||||
$directories = File::directories($this->data_dir);
|
$directories = File::directories($this->data_dir);
|
||||||
foreach ($directories as $directory) {
|
foreach ($directories as $directory) {
|
||||||
$day = substr(strrchr($directory, "/"), 1);
|
$day = substr(strrchr($directory, '/'), 1);
|
||||||
$this->titel = ucfirst($folder) . '-' . $day;
|
$this->titel = ucfirst($folder).'-'.$day;
|
||||||
$this->make_file($this->data_dir . '/' . $day);
|
$this->make_file($this->data_dir.'/'.$day);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'range':
|
case 'range':
|
||||||
$task = SofaScoreTask::with('sport')->where('id', 3)->first();
|
$task = SofaScoreTask::with('sport')->where('id', 3)->first();
|
||||||
$this->titel = ucfirst($folder) . '-' . $this->clean_string($task->name);
|
$this->titel = ucfirst($folder).'-'.$this->clean_string($task->name);
|
||||||
|
$this->make_file($this->data_dir);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'rose_major':
|
||||||
|
case 'rose_others':
|
||||||
|
$day = Carbon::now()->subDay()->format('Y-m-d');
|
||||||
|
|
||||||
|
$this->titel = ucfirst($folder).'-'.$day;
|
||||||
$this->make_file($this->data_dir);
|
$this->make_file($this->data_dir);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -67,7 +76,7 @@ trait GrappingToExcel
|
|||||||
}
|
}
|
||||||
|
|
||||||
$spreadsheet = new Spreadsheet;
|
$spreadsheet = new Spreadsheet;
|
||||||
$spreadsheet->getProperties()->setTitle($this->titel . '-' . $count_from . '-' . $count_to);
|
$spreadsheet->getProperties()->setTitle($this->titel.'-'.$count_from.'-'.$count_to);
|
||||||
$activeWorksheet = $spreadsheet->getActiveSheet();
|
$activeWorksheet = $spreadsheet->getActiveSheet();
|
||||||
|
|
||||||
$column = 1;
|
$column = 1;
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ return new class extends Migration
|
|||||||
$table->integer('sofa_score_category_id')->index();
|
$table->integer('sofa_score_category_id')->index();
|
||||||
$table->string('slug')->index();
|
$table->string('slug')->index();
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
|
$table->boolean('major')->index()->default(0);
|
||||||
$table->boolean('enabled')->index()->default(0);
|
$table->boolean('enabled')->index()->default(0);
|
||||||
$table->boolean('disabled')->index()->default(0);
|
$table->boolean('disabled')->index()->default(0);
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
Schema::create('rosa_tournaments', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->timestamps();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::dropIfExists('rosa_tournaments');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Reference in new issue
Block a user