From 668310b03dc037d59abfadd9e76e468567dc315f Mon Sep 17 00:00:00 2001 From: salam Date: Sun, 4 Jan 2026 13:52:14 +0100 Subject: [PATCH] wip --- app/Console/Commands/Grapper/Magloo/Odds.php | 18 +++++- app/Console/Commands/Grapper/TxOdds/Odds.php | 2 +- .../Commands/Grapper/TxOdds/Odds/_Tq.php | 4 +- .../Supervisors/Tables/SupervisorsTable.php | 9 ++- app/Filament/Tables/Columns/Column3way.php | 53 +++++----------- app/Models/EventBookmaker.php | 1 + ...5_112701_create_event_bookmakers_table.php | 1 + .../seeders/RolesAndPermissionsSeeder.php | 4 +- database/seeders/SupervisorSeeder.php | 13 ++-- .../tables/columns/column_3way.blade.php | 61 ++++--------------- .../columns/fumetto/fumetto_1x2.blade.php | 19 ++---- .../tables/columns/multiline/odds.blade.php | 26 +++++--- 12 files changed, 87 insertions(+), 124 deletions(-) diff --git a/app/Console/Commands/Grapper/Magloo/Odds.php b/app/Console/Commands/Grapper/Magloo/Odds.php index 3b731eb6..835410eb 100644 --- a/app/Console/Commands/Grapper/Magloo/Odds.php +++ b/app/Console/Commands/Grapper/Magloo/Odds.php @@ -8,13 +8,14 @@ use App\Console\Commands\Grapper\Magloo\Odds\FilterTotals; use App\Console\Commands\Grapper\Magloo\Odds\FilterTotalsQ1; use App\Console\Commands\Nuh; use App\Models\Event; +use App\Models\EventBookmaker; use App\Models\Odds3way; use App\Models\OddsDc; use App\Models\OddsHandicap; use App\Models\OddsHandicapQ1; -use App\Models\OddsQualify; use App\Models\OddsTotal; use App\Models\OddsTotalQ1; +use App\Models\OddsTq; use App\Models\Sport; use App\Utilities\Margin; use App\Utilities\Notice; @@ -27,6 +28,8 @@ class Odds $debug = Nuh::$options['d'] ?? 0; $proxy = Nuh::$options['p'] ?? 0; + $event_id_collector = []; + $sportmap = Sport::map('magl', 1, [1, 3]); if ($proxy) { @@ -76,7 +79,12 @@ class Odds $base['bmoid'] = preg_replace('/\D/', '', $match['i']); $base['flag'] = 1; - // dd($match['M']); + $event_id_collector[] = $event_id; + + EventBookmaker::updateOrCreate([ + 'event_id' => $event_id, + 'bookmaker_id' => $bookmaker_id, + ], ['in_feed' => 1, 'bmoid' => $base['bmoid']]); foreach ($match['M'] as $magloo_bettype_id => $value) { switch ($magloo_bettype_id) { @@ -102,7 +110,7 @@ class Odds $odds['atq'] = $value['static'][5] ?? 1; $odds['margin'] = (float) Margin::calculate($odds, 1); - OddsQualify::updateOrCreate([ + OddsTq::updateOrCreate([ 'event_id' => $event_id, 'bookmaker_id' => $bookmaker_id, ], $base + $odds); @@ -189,5 +197,9 @@ class Odds } } + EventBookmaker::whereNotIn('event_id', $event_id_collector) + ->where('bookmaker_id', $bookmaker_id) + ->update(['in_feed' => 0]); + } } diff --git a/app/Console/Commands/Grapper/TxOdds/Odds.php b/app/Console/Commands/Grapper/TxOdds/Odds.php index 8d15d652..0e3fd687 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds.php @@ -157,7 +157,7 @@ class Odds } if ($debug) { - Notice::note('call counter: '.$counter, 'g'); + Notice::note('counter: '.count($_calls).'/'.$counter, 'g'); } foreach ($data as $row) { diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_Tq.php b/app/Console/Commands/Grapper/TxOdds/Odds/_Tq.php index 8ca8668a..06ca19b0 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_Tq.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_Tq.php @@ -3,7 +3,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds; use App\Console\Commands\Nuh; -use App\Models\OddsQualify; +use App\Models\OddsTq; use App\Utilities\Margin; use App\Utilities\Notice; @@ -23,7 +23,7 @@ class _Tq } $odds['margin'] = (float) Margin::calculate([$odds['htq'], $odds['atq']], 1); - OddsQualify::updateOrCreate([ + OddsTq::updateOrCreate([ 'event_id' => Nuh::$id, 'bookmaker_id' => Nuh::$bookmaker_id, ], $odds); diff --git a/app/Filament/Resources/Supervisors/Tables/SupervisorsTable.php b/app/Filament/Resources/Supervisors/Tables/SupervisorsTable.php index 375bf1c4..48f407bb 100644 --- a/app/Filament/Resources/Supervisors/Tables/SupervisorsTable.php +++ b/app/Filament/Resources/Supervisors/Tables/SupervisorsTable.php @@ -8,6 +8,8 @@ use Filament\Actions\EditAction; use Filament\Tables\Columns\SelectColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\ToggleColumn; +use Filament\Tables\Enums\FiltersLayout; +use Filament\Tables\Filters\SelectFilter; use Filament\Tables\Table; class SupervisorsTable @@ -42,8 +44,11 @@ class SupervisorsTable ToggleColumn::make('is_active')->label('On/Off'), ]) ->filters([ - // - ]) + SelectFilter::make('provider_id') + ->relationship('provider', 'name') + ->label('Provider'), + ], layout: FiltersLayout::AboveContent) + ->deferFilters(false) ->recordActions([ EditAction::make(), ]) diff --git a/app/Filament/Tables/Columns/Column3way.php b/app/Filament/Tables/Columns/Column3way.php index 78ca883f..26cd199b 100644 --- a/app/Filament/Tables/Columns/Column3way.php +++ b/app/Filament/Tables/Columns/Column3way.php @@ -8,18 +8,14 @@ class Column3way extends Column { protected string $view = 'filament.tables.columns.column_3way'; - protected ?array $max; - - protected ?array $min; - - protected ?array $act; - protected ?array $bookmakers; protected ?bool $has_data; public function bookmakers(?array $bookmakers): static { + array_unshift($bookmakers, auth()->user()->bookmaker_id); + $this->bookmakers = $bookmakers; return $this; @@ -32,40 +28,23 @@ class Column3way extends Column public function loadData($record) { - $this->max['h3w'] = $record->odds_3way->max('h3w'); - $this->min['h3w'] = $record->odds_3way->min('h3w'); - $this->act['h3w'] = $record->odds_3way->where('bookmaker_id', auth()->user()->bookmaker_id); - - $this->max['d3w'] = $record->odds_3way->max('d3w'); - $this->min['d3w'] = $record->odds_3way->min('d3w'); - $this->act['d3w'] = $record->odds_3way->where('bookmaker_id', auth()->user()->bookmaker_id)->get('d3w'); - - $this->max['a3w'] = $record->odds_3way->max('a3w'); - $this->min['a3w'] = $record->odds_3way->min('a3w'); - $this->act['a3w'] = $record->odds_3way->where('bookmaker_id', auth()->user()->bookmaker_id)->get('a3w'); - - $this->max['margin'] = $record->odds_3way->max('margin'); - $this->min['margin'] = $record->odds_3way->min('margin'); - $this->act['margin'] = $record->odds_3way->where('bookmaker_id', auth()->user()->bookmaker_id)->get('margin'); - - dd($this->act); - $this->has_data = count($record->odds_3way) ? true : false; - } - public function getAct() - { - return $this->act; - } + $tmp = []; + $tmp['max_h3w'] = $record->odds_3way->max('h3w'); + $tmp['min_h3w'] = $record->odds_3way->min('h3w'); + $tmp['max_d3w'] = $record->odds_3way->max('d3w'); + $tmp['min_d3w'] = $record->odds_3way->min('d3w'); + $tmp['max_a3w'] = $record->odds_3way->max('a3w'); + $tmp['min_a3w'] = $record->odds_3way->min('a3w'); - public function getMax() - { - return $this->max; - } - - public function getMin() - { - return $this->min; + foreach ($record->odds_3way as $key => $value) { + if ($value->h3w == $tmp['max_h3w']) { + $record->odds_3way->key->max_h3w = true; + } else { + $record->odds_3way->key->max_h3w = false; + } + } } public function hasData() diff --git a/app/Models/EventBookmaker.php b/app/Models/EventBookmaker.php index 31c76049..9de50fdb 100644 --- a/app/Models/EventBookmaker.php +++ b/app/Models/EventBookmaker.php @@ -10,6 +10,7 @@ class EventBookmaker extends Model 'event_id', 'bookmaker_id', 'bmoid', + 'in_feed', 'send_status', 'bkm_starttime', ]; diff --git a/database/migrations/2023_05_25_112701_create_event_bookmakers_table.php b/database/migrations/2023_05_25_112701_create_event_bookmakers_table.php index 023df9eb..615ba839 100644 --- a/database/migrations/2023_05_25_112701_create_event_bookmakers_table.php +++ b/database/migrations/2023_05_25_112701_create_event_bookmakers_table.php @@ -16,6 +16,7 @@ return new class extends Migration $table->foreignId('event_id')->index()->constrained()->cascadeOnDelete()->references('id')->on('events'); $table->integer('bookmaker_id')->index()->references('id')->on('bookmakers'); $table->string('bmoid')->nullable(); + $table->boolean('in_feed')->default(0); $table->boolean('send_status')->default(0); $table->timestamp('bkm_starttime')->nullable(); $table->timestamps(); diff --git a/database/seeders/RolesAndPermissionsSeeder.php b/database/seeders/RolesAndPermissionsSeeder.php index fd1c2ba0..31062bd5 100644 --- a/database/seeders/RolesAndPermissionsSeeder.php +++ b/database/seeders/RolesAndPermissionsSeeder.php @@ -27,7 +27,7 @@ class RolesAndPermissionsSeeder extends Seeder 'email_verified_at' => now(), 'client_id' => 1, 'sport_id' => 1, - 'bookmaker_id' => 20, + 'bookmaker_id' => 10, 'provider_id' => 4, ]); $user->assignRole('super_admin'); @@ -42,7 +42,7 @@ class RolesAndPermissionsSeeder extends Seeder 'email_verified_at' => now(), 'client_id' => 1, 'sport_id' => 1, - 'bookmaker_id' => 20, + 'bookmaker_id' => 10, 'provider_id' => 4, ]); $user->assignRole('super_admin'); diff --git a/database/seeders/SupervisorSeeder.php b/database/seeders/SupervisorSeeder.php index 85ab1f61..e88f945e 100644 --- a/database/seeders/SupervisorSeeder.php +++ b/database/seeders/SupervisorSeeder.php @@ -14,17 +14,18 @@ class SupervisorSeeder extends Seeder */ $sql = "INSERT INTO `supervisors` (`id`, `name`, `provider_id`, `sport_id`, `sleep`, `limit`, `runtime`, `maxsconds`, `lastcall`, `is_cron`, `is_active`, `created_at`, `updated_at`) VALUES - (1, 'Fixtures', 1, 1, 10, 0, '0.59', 1800, 0, 1, 1, '2025-08-27 07:39:55', '2026-01-03 09:55:09'), + (1, 'Fixtures', 1, 1, 10, 0, '0.073', 1800, 0, 1, 1, '2025-08-27 07:39:55', '2026-01-04 10:09:15'), (2, 'Odds', 1, 1, 10, 0, '0.251', 30, 0, 0, 1, '2025-12-01 05:41:02', '2025-12-22 05:20:40'), - (3, 'Fixtures', 2, 0, 15, 0, NULL, 1800, 0, 1, 1, '2025-12-19 11:42:35', '2025-12-22 06:41:47'), - (4, 'Willhill', 2, 0, 15, 0, '0.235', 1800, 0, 1, 1, '2025-12-19 11:48:05', '2025-12-22 06:41:51'), - (5, 'Bwin', 2, 0, 15, 0, '0.436', 1800, 0, 1, 1, '2025-12-22 06:41:18', '2026-01-03 10:12:40'), + (3, 'Fixtures', 2, 0, 15, 0, '0.133', 1800, 0, 1, 1, '2025-12-19 11:42:35', '2026-01-04 10:25:00'), + (4, 'Willhill', 2, 0, 15, 0, '2.119', 1800, 0, 1, 1, '2025-12-19 11:48:05', '2026-01-04 10:27:11'), + (5, 'Bwin', 2, 0, 15, 0, '0.084', 1800, 0, 1, 1, '2025-12-22 06:41:18', '2026-01-04 10:29:32'), (6, 'Bet365', 2, 0, 10, 0, '0', 30, 0, 0, 1, '2025-12-18 17:44:33', '2026-01-01 17:09:28'), (7, 'Betfair', 2, 0, 10, 0, '0', 30, 0, 0, 0, '2025-12-18 17:44:33', '2026-01-03 12:28:09'), (8, 'Fixtures', 4, 0, 10, 0, '1.368', 30, 0, 1, 1, '2025-12-18 17:44:33', '2026-01-03 12:24:52'), - (9, 'Odds', 4, 0, 15, 0, NULL, 1800, 0, 0, 1, '2026-01-03 12:27:44', '2026-01-03 12:27:53'); + (9, 'Odds', 4, 0, 15, 0, NULL, 1800, 0, 0, 1, '2026-01-03 12:27:44', '2026-01-03 12:27:53'), + (10, 'Fixtures', 3, 0, 10, 0, '1.368', 30, 0, 1, 1, '2025-12-18 17:44:33', '2026-01-03 12:24:52'), + (11, 'Odds', 3, 0, 15, 0, NULL, 1800, 0, 0, 1, '2026-01-03 12:27:44', '2026-01-03 12:27:53'); "; DB::unprepared($sql); - } } diff --git a/resources/views/filament/tables/columns/column_3way.blade.php b/resources/views/filament/tables/columns/column_3way.blade.php index a4494e36..24a2d005 100644 --- a/resources/views/filament/tables/columns/column_3way.blade.php +++ b/resources/views/filament/tables/columns/column_3way.blade.php @@ -4,57 +4,15 @@ @if ($hasData()) - @include('filament.tables.columns.fumetto.fumetto_1x2') + {{-- @include('filament.tables.columns.fumetto.fumetto_1x2') --}}
@include('filament.tables.columns.multiline.label', ['labels' => ['1', 'X', '2']]) - @foreach ($record->odds_3way as $item) - @if ($item->bookmaker_id == auth()->user()->bookmaker_id) - @include('filament.tables.columns.multiline.bkm', [ - 'bookmaker_id' => $item->bookmaker_id, - 'icon' => $item->bookmaker->icon ?? '', - ]) - - @include('filament.tables.columns.multiline.odds', [ - 'odd' => $item->h3w, - 'decimal' => 2, - 'max' => false, - 'min' => false, - ]) - - @include('filament.tables.columns.multiline.odds', [ - 'odd' => $item->d3w, - 'decimal' => 2, - 'max' => false, - 'min' => false, - ]) - - @include('filament.tables.columns.multiline.odds', [ - 'odd' => $item->a3w, - 'decimal' => 2, - 'max' => false, - 'min' => false, - ]) - - @include('filament.tables.columns.multiline.odds', [ - 'odd' => $item->margin, - 'decimal' => 1, - 'max' => false, - 'min' => false, - ]) - @endif - @endforeach - -
- - @php - $act = $getAct(); - @endphp - @foreach ($getBookmaker() as $bookmaker_id) @foreach ($record->odds_3way as $item) + @if ($item->bookmaker_id == $bookmaker_id) @include('filament.tables.columns.multiline.bkm', [ 'bookmaker_id' => $item->bookmaker_id, @@ -63,29 +21,32 @@ @include('filament.tables.columns.multiline.odds', [ 'odd' => $item->h3w, - 'decimal' => 2, + 'dec' => 2, + 'hig' => $item->max_h3w, 'max' => false, 'min' => false, - 'over' => $item->d3w < $act['h3w'] ? 1 : 0, ]) @include('filament.tables.columns.multiline.odds', [ 'odd' => $item->d3w, - 'decimal' => 2, + 'dec' => 2, + 'hig' => false, 'max' => false, 'min' => false, ]) - + @include('filament.tables.columns.multiline.odds', [ 'odd' => $item->a3w, - 'decimal' => 2, + 'dec' => 2, + 'hig' => false, 'max' => false, 'min' => false, ]) @include('filament.tables.columns.multiline.odds', [ 'odd' => $item->margin, - 'decimal' => 1, + 'dec' => 1, + 'hig' => false, 'max' => false, 'min' => false, ]) diff --git a/resources/views/filament/tables/columns/fumetto/fumetto_1x2.blade.php b/resources/views/filament/tables/columns/fumetto/fumetto_1x2.blade.php index 9dbbe96f..353c29b9 100644 --- a/resources/views/filament/tables/columns/fumetto/fumetto_1x2.blade.php +++ b/resources/views/filament/tables/columns/fumetto/fumetto_1x2.blade.php @@ -5,11 +5,6 @@ @include('filament.tables.columns.multiline.label', ['labels' => ['1', 'X', '2']]) - @php - $max = $getMax(); - $min = $getMin(); - @endphp - @foreach ($record->odds_3way as $item) @include('filament.tables.columns.multiline.bkm', [ 'bookmaker_id' => $item->bookmaker_id, @@ -19,29 +14,27 @@ @include('filament.tables.columns.multiline.odds', [ 'odd' => $item->h3w, 'decimal' => 2, - 'max' => $item->h3w == $max['h3w'] ? 1 : 0, - 'min' => $item->h3w == $min['h3w'] ? 1 : 0, + 'max' => $item?->max_h3w, + 'min' => $item?->min_h3w, ]) @include('filament.tables.columns.multiline.odds', [ 'odd' => $item->d3w, 'decimal' => 2, - 'max' => $item->d3w == $max['d3w'] ? 1 : 0, - 'min' => $item->d3w == $min['d3w'] ? 1 : 0, + 'max' => $item?->max_d3w, + 'min' => $item?->min_d3w, ]) @include('filament.tables.columns.multiline.odds', [ 'odd' => $item->a3w, 'decimal' => 2, - 'max' => $item->a3w == $max['a3w'] ? 1 : 0, - 'min' => $item->a3w == $min['a3w'] ? 1 : 0, + 'max' => $item?->max_a3w, + 'min' => $item?->min_a3w, ]) @include('filament.tables.columns.multiline.odds', [ 'odd' => $item->margin, 'decimal' => 1, - 'max' => $item->margin == $max['margin'] ? 1 : 0, - 'min' => $item->margin == $min['margin'] ? 1 : 0, ]) @endforeach
diff --git a/resources/views/filament/tables/columns/multiline/odds.blade.php b/resources/views/filament/tables/columns/multiline/odds.blade.php index 98ee6ff4..857f03eb 100644 --- a/resources/views/filament/tables/columns/multiline/odds.blade.php +++ b/resources/views/filament/tables/columns/multiline/odds.blade.php @@ -1,11 +1,21 @@ -
-   - @if (isset($odd)) - {{ number_format($odd, $decimal) }} +
+   + @if (isset($odd)) + {{ number_format($odd, $dec) }} + @endif