fix mapper
This commit is contained in:
1 parent
b4b3f1e1ea
commit
336af556a1
9 files changed
+893
-1432
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\Events;
|
||||
use App\Console\Commands\Grapper\Sofascore\Tournament;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreCategorie;
|
||||
@@ -31,13 +32,16 @@ class Sofascore
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(Nuh::$options['sport'].' '.Nuh::$options['name'], 'b');
|
||||
Notice::note(Nuh::$options['sport'] . ' ' . Nuh::$options['name'], 'b');
|
||||
}
|
||||
|
||||
switch (Nuh::$options['name']) {
|
||||
case 'TOURNAMENTS':
|
||||
Tournament::load();
|
||||
break;
|
||||
case 'EVENTS':
|
||||
Events::load();
|
||||
break;
|
||||
|
||||
default:
|
||||
// code...
|
||||
|
||||
@@ -20,13 +20,18 @@ class Events
|
||||
|
||||
public static $sport = [1];
|
||||
|
||||
public static function switch()
|
||||
public static function load()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$sportmap = Sport::whereIn('id', self::$sport)->select('id', 'sofascore', 'ss_slug')->get();
|
||||
$sport_id = Nuh::$options['sport_id'];
|
||||
|
||||
$time_zone_offset = 0;
|
||||
$sport = Sport::where('id', $sport_id)->first();
|
||||
|
||||
$dates = Carbon::now();
|
||||
|
||||
// to grap event id
|
||||
// https://www.sofascore.com/api/v1/unique-tournament/2480/scheduled-events/2022-05-19
|
||||
|
||||
$years_back = 7;
|
||||
|
||||
@@ -46,7 +51,7 @@ class Events
|
||||
$page = 1;
|
||||
|
||||
while ($page) {
|
||||
$url = Nuh::$options['base_url']."api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page";
|
||||
$url = Nuh::$options['base_url'] . "api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page";
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
|
||||
@@ -16,12 +16,6 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Tournament
|
||||
{
|
||||
public static $auth_header = [];
|
||||
|
||||
public static $base_url = '';
|
||||
|
||||
public static $sport = [1];
|
||||
|
||||
public static function load()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
@@ -44,13 +38,13 @@ class Tournament
|
||||
if (! SofaScoreDay::where('day', $day)->where($sport->ss_slug, 1)->first()) {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('Grapping Sport: '.Nuh::$options['sport'].' Day: '.$day, 'g');
|
||||
Notice::note('Grapping Sport: ' . Nuh::$options['sport'] . ' Day: ' . $day, 'g');
|
||||
}
|
||||
|
||||
$page = 1;
|
||||
|
||||
while ($page) {
|
||||
$url = Nuh::$options['base_url']."api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page";
|
||||
$url = Nuh::$options['base_url'] . "api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
if ($debug) {
|
||||
@@ -164,7 +158,6 @@ class Tournament
|
||||
Notice::note("tournaments: $tournaments_counter", 'p');
|
||||
|
||||
SofaScoreDay::updateOrCreate(['day' => $day], [$sport->ss_slug => 1]);
|
||||
|
||||
}
|
||||
|
||||
if (Nuh::$options['test']) {
|
||||
@@ -172,7 +165,7 @@ class Tournament
|
||||
}
|
||||
} else {
|
||||
if ($debug) {
|
||||
Notice::note('Having Sport: '.Nuh::$options['sport'].' Day: '.$day, 'b');
|
||||
Notice::note('Having Sport: ' . Nuh::$options['sport'] . ' Day: ' . $day, 'b');
|
||||
}
|
||||
}
|
||||
$dates->subDay();
|
||||
|
||||
+37
-3
@@ -6,6 +6,7 @@ use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Tables\Columns\CheckboxColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
@@ -28,20 +29,53 @@ class SofaScoreDaysTable
|
||||
])
|
||||
->filters([
|
||||
Filter::make('day')
|
||||
->columns(2)->columnSpan(2)
|
||||
->columns(3)->columnSpan(3)
|
||||
->schema([
|
||||
DatePicker::make('from')->native(),
|
||||
DatePicker::make('until')->native(),
|
||||
Select::make('sports-grapper')
|
||||
->options([
|
||||
'1' => 'Soccer Grapped',
|
||||
'2' => 'Soccer Not Grapped',
|
||||
'3' => 'Basketball Grapped',
|
||||
'4' => 'Basketball Not Grapped',
|
||||
'5' => 'Ice-Hockey Grapped',
|
||||
'6' => 'Ice-Hockey Not Grapped',
|
||||
'7' => 'Tennis Grapped',
|
||||
'8' => 'Tennis Not Grapped',
|
||||
]),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['from'],
|
||||
fn (Builder $query, $date): Builder => $query->whereDate('day', '>=', $date),
|
||||
fn(Builder $query, $date): Builder => $query->whereDate('day', '>=', $date),
|
||||
)
|
||||
->when(
|
||||
$data['until'],
|
||||
fn (Builder $query, $date): Builder => $query->whereDate('day', '<=', $date),
|
||||
fn(Builder $query, $date): Builder => $query->whereDate('day', '<=', $date),
|
||||
)->when(
|
||||
$data['sports-grapper'],
|
||||
function (Builder $query, $sports_grapper) {
|
||||
switch ($sports_grapper) {
|
||||
case 1:
|
||||
return $query->where('football', 1);
|
||||
case 2:
|
||||
return $query->where('football', 0);
|
||||
case 3:
|
||||
return $query->where('basketball', 1);
|
||||
case 4:
|
||||
return $query->where('basketball', 0);
|
||||
case 5:
|
||||
return $query->where('ice-hockey', 1);
|
||||
case 6:
|
||||
return $query->where('ice-hockey', 0);
|
||||
case 7:
|
||||
return $query->where('tennis', 1);
|
||||
case 8:
|
||||
return $query->where('tennis', 0);
|
||||
}
|
||||
}
|
||||
);
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
|
||||
+22
-24
@@ -3,18 +3,19 @@
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTournaments\Tables;
|
||||
|
||||
use App\Models\SofaScoreCategorie;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\BulkAction;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Support\Enums\IconSize;
|
||||
use Filament\Tables\Columns\CheckboxColumn;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\TernaryFilter;
|
||||
@@ -27,25 +28,28 @@ class SofaScoreTournamentsTable
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->poll()
|
||||
->columns([
|
||||
IconColumn::make('sport.icon')
|
||||
->label('')
|
||||
->grow(false)
|
||||
->width(30)
|
||||
->color(fn ($record) => $record->sport->color)
|
||||
->icon(fn ($record) => $record->sport->icon)
|
||||
->color(fn($record) => $record->sport->color)
|
||||
->icon(fn($record) => $record->sport->icon)
|
||||
->size(IconSize::Medium)
|
||||
->tooltip(fn ($record) => $record->id)
|
||||
->tooltip(fn($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
TextColumn::make('tournament_id'),
|
||||
TextColumn::make('sport.name'),
|
||||
TextColumn::make('sofascore_category.name')
|
||||
->icon(fn ($record) => $record->sofascore_category->country->icon),
|
||||
->icon(fn($record) => $record->sofascore_category->country->icon),
|
||||
TextColumn::make('name')->searchable()->sortable(),
|
||||
CheckboxColumn::make('grap'),
|
||||
ToggleColumn::make('grap')->tooltip('When active liga will be grapped'),
|
||||
ToggleColumn::make('grapped')->onColor('success')->tooltip('When active liga has been grapped, to grap again disactivate'),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('filters')
|
||||
->columns(2)->columnSpan(2)
|
||||
->columns(3)->columnSpan(3)
|
||||
->schema([
|
||||
Select::make('sport_id')
|
||||
->default(1)
|
||||
@@ -69,22 +73,14 @@ class SofaScoreTournamentsTable
|
||||
return SofaScoreCategorie::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||
})
|
||||
->live(),
|
||||
// Select::make('competition_group_id')
|
||||
// ->searchable()
|
||||
// ->label('Competition Group')
|
||||
// ->options(function (Get $get) {
|
||||
// if ($get('country_id')) {
|
||||
// return CompetitionGroup::where('country_id', $get('country_id'))->orderBy('name')->pluck('name', 'id');
|
||||
// } else {
|
||||
// return CompetitionGroup::orderBy('name')->pluck('name', 'id');
|
||||
// }
|
||||
// }),
|
||||
DatePicker::make('day')->live(),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
$data['sport_id'],
|
||||
fn (Builder $query, $sport_id) => $query->where('sport_id', $sport_id)
|
||||
)->when($data['sofa_score_categorie_id'],
|
||||
fn(Builder $query, $sport_id) => $query->where('sport_id', $sport_id)
|
||||
)->when(
|
||||
$data['sofa_score_categorie_id'],
|
||||
function (Builder $query, $sofa_score_categorie_id) {
|
||||
if (is_array($sofa_score_categorie_id)) {
|
||||
$query->whereIn('sofa_score_categorie_id', $sofa_score_categorie_id);
|
||||
@@ -92,17 +88,19 @@ class SofaScoreTournamentsTable
|
||||
$query->where('sofa_score_categorie_id', $sofa_score_categorie_id);
|
||||
}
|
||||
}
|
||||
)->when(
|
||||
$data['day'],
|
||||
function (Builder $query, $day) {
|
||||
$res = SofaScoreDayTournament::where('day', $day)->pluck('tournament_id')->toArray();
|
||||
$query->whereIn('tournament_id', $res);
|
||||
}
|
||||
);
|
||||
}),
|
||||
TernaryFilter::make('grap')->placeholder('All')->label('Grapping'),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
// EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
// DeleteBulkAction::make(),
|
||||
BulkAction::make('Grap On')
|
||||
->icon('phosphor-play')
|
||||
->action(function (Collection $records): void {
|
||||
|
||||
@@ -18,7 +18,7 @@ class StoreMapped
|
||||
|
||||
$mapper = Mapper::where('event_id', $arguments['event_id'])->first();
|
||||
|
||||
dd($mapper, $arguments, $swopped);
|
||||
// dd($mapper, $arguments, $swopped);
|
||||
|
||||
/*
|
||||
EVENT
|
||||
|
||||
@@ -14,6 +14,7 @@ class SofaScoreTournament extends Model
|
||||
'name',
|
||||
'slug',
|
||||
'grap',
|
||||
'grapped',
|
||||
];
|
||||
|
||||
public function sport()
|
||||
|
||||
@@ -19,6 +19,7 @@ return new class extends Migration
|
||||
$table->string('slug')->index();
|
||||
$table->string('name');
|
||||
$table->boolean('grap')->index()->default(0);
|
||||
$table->boolean('grapped')->index()->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
+814
-1389
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user