alarm wip

This commit is contained in:
salam committed 2026-01-27 20:13:41 +01:00
1 parent d81af0b02b
commit 04b17abd30
15 files changed
+302 -61

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
<?php
namespace App\Actions;
use App\Models\EventBookmaker;
use App\Models\OddsTable;
class AlarmStatistic
{
public static function load()
{
$res = OddsTable::select('name', 'fieldnames')->get();
$fields = [];
foreach ($res as $value) {
$fields[$value->name] = explode(',', $value->fieldnames);
}
$res = EventBookmaker::select('alarm_2w_h2w', 'alarm_2w_a2w', 'alarm_2ws1_h2w', 'alarm_2ws1_a2w', 'alarm_3w_h3w', 'alarm_3w_d3w', 'alarm_3w_a3w', 'alarm_3wht_h3w', 'alarm_3wht_d3w', 'alarm_3wht_a3w', 'alarm_dc_dc1x', 'alarm_dc_dc12', 'alarm_dc_dcx2', 'alarm_dbn_dnb1', 'alarm_dbn_dnb2', 'alarm_ggng_gg', 'alarm_ggng_ng', 'alarm_po_home', 'alarm_po_away', 'alarm_poht_home', 'alarm_poht_away', 'alarm_poq1_home', 'alarm_poq1_away', 'alarm_to_over', 'alarm_to_under', 'alarm_toht_over', 'alarm_toht_under', 'alarm_toq1_over', 'alarm_toq1_under', 'alarm_tq_htq', 'alarm_tq_atq')
->where('bookmaker_id', auth()->user()->bookmaker_id)
->where('sport_id', auth()->user()->sport_id)
->get()
->toArray();
$arr = [];
foreach ($res as $value) {
foreach ($fields as $table => $names) {
foreach ($names as $name) {
$val = (int) $value[$name];
if ($val) {
if (isset($arr[$table][$val])) {
$arr[$table][$val]++;
} else {
$arr[$table][$val] = 1;
}
}
}
}
}
return $arr;
}
}
@@ -8,19 +8,82 @@ class AlarmLoadOdds
{
public static function get($event_id, $table, $oddnames)
{
$res = DB::table($table)->where('flags', 1)->where('event_id', $event_id)->get();
$odds = explode(',', $oddnames);
$arr = [];
foreach ($res as $value) {
if ($table == 'odds_dc') {
$arr[(int) $value->bookmaker_id]['margin'] = (float) $value->margin * 2;
} else {
$arr[(int) $value->bookmaker_id]['margin'] = (float) $value->margin;
}
foreach ($odds as $odd) {
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->$odd;
foreach ($oddnames as $odd) {
switch ($odd) {
case 'h3w':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->h3w;
break;
case 'd3w':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->d3w;
break;
case 'a3w':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->a3w;
break;
case 'h2w':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->d3w;
break;
case 'a2w':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->a3w;
break;
case 'dnb1':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->dnb1;
break;
case 'dnb2':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->dnb2;
break;
case 'gg':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->gg;
break;
case 'ng':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->ng;
break;
case 'dc1x':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->dc1x;
break;
case 'dc12':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->dc12;
break;
case 'dcx2':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->dcx2;
break;
case 'home':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->home;
break;
case 'away':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->away;
break;
case 'over':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->over;
break;
case 'under':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->under;
break;
case 'htq':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->htq;
break;
case 'atq':
$arr[(int) $value->bookmaker_id][$odd] = (float) $value->atq;
break;
}
}
}
@@ -3,17 +3,11 @@
namespace App\Console\Commands\Services\Tasks\Alarm;
use App\Models\EventBookmaker;
use App\Models\OddsTable;
class AlarmStore
{
public static function get($event_id, $table, $client_bookmaker_id, $alarm_threshold, $compare_odds, $client_odds)
public static function get($event_id, $oddnames, $client_bookmaker_id, $alarm_threshold, $compare_odds, $client_odds)
{
$res = OddsTable::where($table)->value('oddnames');
$oddnames = explode(',', $res);
dd($oddnames);
if (! $compare_odds) {
return;
}
@@ -22,21 +16,11 @@ class AlarmStore
return;
}
/**
* get favorit
*/
$favorit = 100;
foreach ($oddnames as $fieldname => $oddname) {
if ($client_odds[$oddname] < $favorit) {
$favorit = $oddname;
}
}
/**
* evaluate
*/
$favorit = min($client_odds);
$update_array = [];
foreach ($oddnames as $fieldname => $oddname) {
if ($oddname == $favorit) {
if ($client_odds[$oddname] == $favorit) {
$threshold = $client_odds[$oddname] - $compare_odds[$oddname];
@@ -12,6 +12,7 @@ use App\Console\Commands\Services\Tasks\Alarm\AlarmSettings;
use App\Console\Commands\Services\Tasks\Alarm\AlarmStore;
use App\Models\Client;
use App\Models\EventBookmaker;
use App\Models\OddsTable;
use App\Models\Sport;
use App\Utilities\Notice;
@@ -26,6 +27,8 @@ class GenerateAlarms
Notice::note('GENERATE ALARMS', 'b');
}
$oddnames = OddsTable::oddnames();
$clients = Client::get();
$sports = Sport::where('is_active', 1)->pluck('id');
@@ -44,17 +47,21 @@ class GenerateAlarms
$res = EventBookmaker::where('bookmaker_id', $client_bookmaker_id)->where('sport_id', $sport_id)->get();
// $res = EventBookmaker::where('event_id', 14597944)->where('bookmaker_id', $client_bookmaker_id)->where('sport_id', $sport_id)->get();
foreach ($res as $event) {
foreach ($multilines as $multiline_id => $multiline) {
$odds = AlarmLoadOdds::get($event->event_id, $multiline['table'], $multiline['oddnames']);
$table = $multiline['table'];
$odds = AlarmLoadOdds::get($event->event_id, $table, $oddnames[$table]);
$compare_odds = AlarmFilterCompare::get($odds, $filter);
$client_odds = AlarmFilterClient::get($odds, $client_bookmaker_id);
AlarmStore::get($event->event_id, $multiline['table'], $client_bookmaker_id, $alarm_threshold[$multiline_id], $compare_odds, $client_odds);
AlarmStore::get($event->event_id, $oddnames[$table], $client_bookmaker_id, $alarm_threshold[$multiline_id], $compare_odds, $client_odds);
}
}
}
@@ -13,7 +13,7 @@ class EditEvent extends EditRecord
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
// DeleteAction::make(),
];
}
}
@@ -3,6 +3,7 @@
namespace App\Filament\Resources\Events\Pages;
use App\Filament\Resources\Events\EventResource;
use App\Filament\Resources\Events\Widgets\AlarmWidget;
use Filament\Resources\Pages\ListRecords;
use Filament\Support\Enums\Width;
@@ -13,4 +14,19 @@ class ListEvents extends ListRecords
protected string|Width|null $maxContentWidth = Width::Full;
protected $listeners = ['refreshBettypeMenu' => '$refresh'];
protected function getHeaderWidgets(): array
{
return [
AlarmWidget::class,
];
}
public function getColumns(): int|array
{
return [
'md' => 4,
'xl' => 6,
];
}
}
@@ -187,8 +187,7 @@ class EventsTable
$livewire->dispatch('reload_bookmaker_multiline');
$livewire->dispatch('reload_alarm_bookmaker');
$livewire->dispatch('refresh_comparing_bookmaker');
// $livewire->dispatch('reload_data_left');
// $livewire->dispatch('reload_data_right');
$livewire->dispatch('refreshAlarmWidget');
$set('country_id', null);
$set('competition_group_id', null);
@@ -0,0 +1,96 @@
<?php
namespace App\Filament\Resources\Events\Widgets;
use App\Actions\AlarmStatistic;
use Filament\Widgets\StatsOverviewWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
class AlarmWidget extends StatsOverviewWidget
{
protected $listeners = [
'refreshAlarmWidget' => '$refresh',
];
protected ?string $pollingInterval = '10s';
protected function getStats(): array
{
$res = AlarmStatistic::load();
switch (auth()->user()->sport_id) {
case 1:
return [
Stat::make('1X2', '1X2')->view('filament.resources.events.widgets.alarm-widget',
['title' => '1X2', 'red' => $res['odds_3ways'][3] ?? 0, 'yellow' => $res['odds_3ways'][2] ?? 0, 'green' => $res['odds_3ways'][1] ?? 0]),
Stat::make('1X2', '1X2')->view('filament.resources.events.widgets.alarm-widget',
['title' => '1X2 HT', 'red' => $res['odds_3ways_ht'][3] ?? 0, 'yellow' => $res['odds_3ways_ht'][2] ?? 0, 'green' => $res['odds_3ways_ht'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'Totals', 'red' => $res['odds_totals'][3] ?? 0, 'yellow' => $res['odds_totals'][2] ?? 0, 'green' => $res['odds_totals'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'Totals HT', 'red' => $res['odds_totals_ht'][3] ?? 0, 'yellow' => $res['odds_totals_ht'][2] ?? 0, 'green' => $res['odds_totals_ht'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'GG NG', 'red' => $res['odds_ggng'][3] ?? 0, 'yellow' => $res['odds_ggng'][2] ?? 0, 'green' => $res['odds_ggng'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'DNB', 'red' => $res['odds_dnb'][3] ?? 0, 'yellow' => $res['odds_dnb'][2] ?? 0, 'green' => $res['odds_dnb'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'DC', 'red' => $res['odds_dc'][3] ?? 0, 'yellow' => $res['odds_dc'][2] ?? 0, 'green' => $res['odds_dc'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'TQ', 'red' => $res['odds_tq'][3] ?? 0, 'yellow' => $res['odds_tq'][2] ?? 0, 'green' => $res['odds_tq'][1] ?? 0]),
];
case 2:
return [
Stat::make('1X2', '1X2')->view('filament.resources.events.widgets.alarm-widget',
['title' => '1X2', 'red' => $res['odds_3ways'][3] ?? 0, 'yellow' => $res['odds_3ways'][2] ?? 0, 'green' => $res['odds_3ways'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'ML', 'red' => $res['odds_2ways'][3] ?? 0, 'yellow' => $res['odds_2ways'][2] ?? 0, 'green' => $res['odds_2ways'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'HC', 'red' => $res['odds_points'][3] ?? 0, 'yellow' => $res['odds_points'][2] ?? 0, 'green' => $res['odds_points'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'HC Q1', 'red' => $res['odds_points_q1'][3] ?? 0, 'yellow' => $res['odds_points_q1'][2] ?? 0, 'green' => $res['odds_points_q1'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'Totals', 'red' => $res['odds_totals'][3] ?? 0, 'yellow' => $res['odds_totals'][2] ?? 0, 'green' => $res['odds_totals'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'Totals Q1', 'red' => $res['odds_totals_q1'][3] ?? 0, 'yellow' => $res['odds_totals_q1'][2] ?? 0, 'green' => $res['odds_totals_q1'][1] ?? 0]),
];
case 3:
return [
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'ML', 'red' => $res['odds_2ways'][3] ?? 0, 'yellow' => $res['odds_2ways'][2] ?? 0, 'green' => $res['odds_2ways'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'HC', 'red' => $res['odds_points'][3] ?? 0, 'yellow' => $res['odds_points'][2] ?? 0, 'green' => $res['odds_points'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'HC Q1', 'red' => $res['odds_points_q1'][3] ?? 0, 'yellow' => $res['odds_points_q1'][2] ?? 0, 'green' => $res['odds_points_q1'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'HC HT', 'red' => $res['odds_points_ht'][3] ?? 0, 'yellow' => $res['odds_points_ht'][2] ?? 0, 'green' => $res['odds_points_ht'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'Totals', 'red' => $res['odds_totals'][3] ?? 0, 'yellow' => $res['odds_totals'][2] ?? 0, 'green' => $res['odds_totals'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'Totals Q1', 'red' => $res['odds_totals_q1'][3] ?? 0, 'yellow' => $res['odds_totals_q1'][2] ?? 0, 'green' => $res['odds_totals_q1'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'Totals HT', 'red' => $res['odds_totals_ht'][3] ?? 0, 'yellow' => $res['odds_totals_ht'][2] ?? 0, 'green' => $res['odds_totals_ht'][1] ?? 0]),
];
case 5:
return [
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'ML', 'red' => $res['odds_2ways'][3] ?? 0, 'yellow' => $res['odds_2ways'][2] ?? 0, 'green' => $res['odds_2ways'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'MLS1', 'red' => $res['odds_2ways_s1'][3] ?? 0, 'yellow' => $res['odds_2ways_s1'][2] ?? 0, 'green' => $res['odds_2ways_s1'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'HC', 'red' => $res['odds_points'][3] ?? 0, 'yellow' => $res['odds_points'][2] ?? 0, 'green' => $res['odds_points'][1] ?? 0]),
Stat::make('', '')->view('filament.resources.events.widgets.alarm-widget',
['title' => 'Totals', 'red' => $res['odds_totals'][3] ?? 0, 'yellow' => $res['odds_totals'][2] ?? 0, 'green' => $res['odds_totals'][1] ?? 0]),
];
}
}
public function getColumns(): int|array
{
return [
'md' => 6,
'xl' => 8,
];
}
}
+1 -1
View File
@@ -319,7 +319,7 @@ class ColumnOdds extends Column
$this->data->filter(function ($model) {
if ($model->bookmaker_id != auth()->user()->bookmaker_id) {
if ($model->flags == 1 && $model->bookmaker_id != auth()->user()->bookmaker_id) {
$filter = $this->filter[$model->bookmaker_id] ?? 0;
+13 -1
View File
@@ -6,5 +6,17 @@ use Illuminate\Database\Eloquent\Model;
class OddsTable extends Model
{
//
public static function oddnames()
{
$res = OddsTable::get();
$arr = [];
foreach ($res as $value) {
$names = explode(',', $value->oddnames);
$fields = explode(',', $value->fieldnames);
$arr[$value->name] = array_combine($fields, $names);
}
return $arr;
}
}
Generated
+3 -3
View File
@@ -12814,12 +12814,12 @@
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {},
"stability-flags": [],
"prefer-stable": true,
"prefer-lowest": false,
"platform": {
"php": "^8.3"
},
"platform-dev": {},
"plugin-api-version": "2.9.0"
"platform-dev": [],
"plugin-api-version": "2.6.0"
}
@@ -15,6 +15,7 @@ return new class extends Migration
$table->id();
$table->string('name');
$table->string('oddnames');
$table->string('fieldnames');
$table->timestamps();
});
}
+15 -16
View File
@@ -12,23 +12,22 @@ class OddsTableSeeder extends Seeder
/**
* Provoider
*/
$sql = "INSERT INTO `odds_tables` (`id`, `name`, `oddnames`, `created_at`, `updated_at`)
$sql = "INSERT INTO `odds_tables` (`id`, `name`, `oddnames`, `fieldnames`, `created_at`, `updated_at`)
VALUES
(1, 'odds_2ways', 'h2w,a2w', NULL, NULL),
(2, 'odds_2ways_s1', 'h2w,a2w', NULL, NULL),
(3, 'odds_3ways', 'h3w,d3w,a3w', NULL, NULL),
(4, 'odds_3ways_ht', 'h3w,d3w,a3w', NULL, NULL),
(5, 'odds_dc', 'dc1x,dc12,dcx2', NULL, NULL),
(6, 'odds_dnb', 'dnb1,dnb2', NULL, NULL),
(7, 'odds_ggng', 'gg,ng', NULL, NULL),
(8, 'odds_points', 'home,away', NULL, NULL),
(9, 'odds_points_ht', 'home,away', NULL, NULL),
(10, 'odds_points_q1', 'home,away', NULL, NULL),
(11, 'odds_totals', 'over,under', NULL, NULL),
(12, 'odds_totals_ht', 'over,under', NULL, NULL),
(13, 'odds_totals_q1', 'over,under', NULL, NULL),
(14, 'odds_tq', 'htq,atq', NULL, NULL);
;
(1, 'odds_2ways', 'h2w,a2w', 'alarm_2w_h2w,alarm_2w_a2w', NULL, NULL),
(2, 'odds_2ways_s1', 'h2w,a2w', 'alarm_2ws1_h2w,alarm_2ws1_a2w', NULL, NULL),
(3, 'odds_3ways', 'h3w,d3w,a3w', 'alarm_3w_h3w,alarm_3w_d3w,alarm_3w_a3w', NULL, NULL),
(4, 'odds_3ways_ht', 'h3w,d3w,a3w', 'alarm_3wht_h3w,alarm_3wht_d3w,alarm_3wht_a3w', NULL, NULL),
(5, 'odds_dc', 'dc1x,dc12,dcx2', 'alarm_dc_dc1x,alarm_dc_dc12,alarm_dc_dcx2', NULL, NULL),
(6, 'odds_dnb', 'dnb1,dnb2', 'alarm_dbn_dnb1,alarm_dbn_dnb2', NULL, NULL),
(7, 'odds_ggng', 'gg,ng', 'alarm_ggng_gg,alarm_ggng_ng', NULL, NULL),
(8, 'odds_points', 'home,away', 'alarm_po_home,alarm_po_away', NULL, NULL),
(9, 'odds_points_ht', 'home,away', 'alarm_poht_home,alarm_poht_away', NULL, NULL),
(10, 'odds_points_q1', 'home,away', 'alarm_poq1_home,alarm_poq1_away', NULL, NULL),
(11, 'odds_totals', 'over,under', 'alarm_to_over,alarm_to_under', NULL, NULL),
(12, 'odds_totals_ht', 'over,under', 'alarm_toht_over,alarm_toht_under', NULL, NULL),
(13, 'odds_totals_q1', 'over,under', 'alarm_toq1_over,alarm_toq1_under', NULL, NULL),
(14, 'odds_tq', 'htq,atq', 'alarm_tq_htq,alarm_tq_atq', NULL, NULL);
";
DB::unprepared($sql);
@@ -0,0 +1,21 @@
<div class="grid grid-cols-2 gap-1 p-1 border border-gray-800 rounded-xl bg-gray-900 text-center" style="font-size: 10.5px;">
<div class="row-span-3 text-lg text-gray-500 pt-3">{{ $title }}</div>
@if($red)
<div class="cursor-pointer"><x-alarm-red>{{ $red }}</x-alarm-red></div>
@else
<x-alarm-neutral>0</x-alarm-neutral>
@endif
@if($yellow)
<div class="cursor-pointer"><x-alarm-yellow>{{ $yellow }}</x-alarm-yellow></div>
@else
<x-alarm-neutral>0</x-alarm-neutral>
@endif
@if($green)
<div class="cursor-pointer"><x-alarm-green>{{ $green }}</x-alarm-green></div>
@else
<x-alarm-neutral>0</x-alarm-neutral>
@endif
</div>
+11 -11
View File
@@ -70,25 +70,25 @@ case "$1" in
echo "!! WITH PROXY !!"
php artisan nuh --d --t --f 1
php artisan nuh --d --t --f 2
php artisan nuh --d --t --f 20
php artisan nuh --d --t --f 21
php artisan nuh --d --t --f 22
# php artisan nuh --d --t --f 20
# php artisan nuh --d --t --f 21
# php artisan nuh --d --t --f 22
php artisan nuh --d --f 2
php artisan nuh --d --f 4
php artisan nuh --d --f 5
php artisan nuh --d --f 6
php artisan nuh --d --f --p 8
php artisan nuh --d --f --p 9
php artisan nuh --d --f --p 10
php artisan nuh --d --f --p 11
# php artisan nuh --d --f --p 10
# php artisan nuh --d --f --p 11
php artisan nuh --d --f --p 12
php artisan nuh --d --f --p 13
php artisan nuh --d --f --p 14
php artisan nuh --d --f --p 15
# php artisan nuh --d --f --p 13
# php artisan nuh --d --f --p 14
# php artisan nuh --d --f --p 15
php artisan nuh --d --f --p 16
php artisan nuh --d --f --p 17
php artisan nuh --d --f --p 18
php artisan nuh --d --f --p 19
# php artisan nuh --d --f --p 17
# php artisan nuh --d --f --p 18
# php artisan nuh --d --f --p 19
;;
*)
echo ""