add txodds markets as a resource
This commit is contained in:
1 parent
e14404ec8b
commit
5fa1d02dbd
26 files changed
+921
-55
No files matched your search
@@ -42,7 +42,7 @@ class SupervisorMaker
|
||||
$content .= 'autorestart=true'.PHP_EOL;
|
||||
|
||||
$file = $path.'/'.$process.'.ini';
|
||||
if ($supervisor->is_active && ! $supervisor->is_cron) {
|
||||
if ($supervisor->is_active && $supervisor->is_supervisor) {
|
||||
file_put_contents($file, $content);
|
||||
chmod($file, 0777);
|
||||
} else {
|
||||
|
||||
@@ -96,8 +96,6 @@ class Odds
|
||||
|
||||
*************************************************/
|
||||
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
switch (Nuh::$options['sport_id']) {
|
||||
case 1:
|
||||
/**
|
||||
@@ -149,6 +147,13 @@ class Odds
|
||||
break;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
* use_lastcall
|
||||
*************************************************/
|
||||
if (Nuh::$options['use_lastcall']) {
|
||||
$lastcall = Nuh::$options['lastcall'] ? '&last='.Nuh::$options['lastcall'] : '';
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
* URL
|
||||
*************************************************/
|
||||
@@ -165,26 +170,15 @@ class Odds
|
||||
Notice::note("BY ID \nsport_id: ".Nuh::$options['sport_id'], 'p');
|
||||
}
|
||||
/**
|
||||
* by SINGLE ID
|
||||
* by specific ID
|
||||
*/
|
||||
$_calls[] = $url."&ot=$markets&peid=".Nuh::$options['id'];
|
||||
} elseif (Nuh::$options['a']) {
|
||||
if ($debug) {
|
||||
Notice::note("ALL \nsport_id: ".Nuh::$options['sport_id'], 'p');
|
||||
}
|
||||
/**
|
||||
* ALL by ID
|
||||
*/
|
||||
$res = Event::where('sport_id', Nuh::$options['sport_id'])->where('starttime', '>', Carbon::now()->toDateTimeString())->pluck('id');
|
||||
foreach ($res as $id) {
|
||||
$_calls[] = $url."&ot=$markets&peid=".$id;
|
||||
}
|
||||
} elseif (Nuh::$options['g']) {
|
||||
if ($debug) {
|
||||
Notice::note("GROUP_ID \nsport_id: ".Nuh::$options['sport_id'], 'p');
|
||||
}
|
||||
/**
|
||||
* PER GROUP_ID
|
||||
* per group_id
|
||||
* with from-to
|
||||
*/
|
||||
$groupids = Event::where('starttime', '>', Carbon::now()->toDateTimeString())->groupBy('group_id')->pluck('group_id');
|
||||
@@ -197,7 +191,7 @@ class Odds
|
||||
}
|
||||
|
||||
/**
|
||||
* TODAY
|
||||
* today
|
||||
*/
|
||||
$from = Carbon::now()->toDateTimeString();
|
||||
$to = Carbon::now()->addDays(1)->toDateTimeString();
|
||||
@@ -211,13 +205,23 @@ class Odds
|
||||
Notice::note("WEEK \nsport_id: ".Nuh::$options['sport_id'], 'p');
|
||||
}
|
||||
/**
|
||||
* ONE WEEK
|
||||
* week from now
|
||||
*/
|
||||
$res = Event::where('sport_id', Nuh::$options['sport_id'])->where('starttime', '>', Carbon::now()->toDateTimeString())->where('starttime', '<', Carbon::now()->addDays(7)->toDateTimeString())->pluck('id');
|
||||
foreach ($res as $id) {
|
||||
$_calls[] = $url."&ot=$markets&peid=".$id;
|
||||
}
|
||||
} else {
|
||||
if ($debug) {
|
||||
Notice::note("ALL \nsport_id: ".Nuh::$options['sport_id'], 'p');
|
||||
}
|
||||
/**
|
||||
* ALL by ID
|
||||
*/
|
||||
$res = Event::where('sport_id', Nuh::$options['sport_id'])->where('starttime', '>', Carbon::now()->toDateTimeString())->pluck('id');
|
||||
foreach ($res as $id) {
|
||||
$_calls[] = $url."&ot=$markets&peid=".$id;
|
||||
}
|
||||
if ($debug) {
|
||||
Notice::note("LASTCALL \nsport_id: ".Nuh::$options['sport_id'], 'p');
|
||||
}
|
||||
@@ -226,7 +230,7 @@ class Odds
|
||||
|
||||
* with from-to days
|
||||
*/
|
||||
$_calls[] = $url.'&spid='.Nuh::$options['sport_id']."&ot=$markets&days=".Nuh::$options['days_from'].','.Nuh::$options['days_to'].'&last='.Nuh::$options['lastcall'];
|
||||
$_calls[] = $url.'&spid='.Nuh::$options['sport_id']."&ot=$markets&days=".Nuh::$options['days_from'].','.Nuh::$options['days_to'].$lastcall;
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Maintenance;
|
||||
|
||||
use App\Console\Commands\Maintenance\Tasks\CallTxoddsMarkets;
|
||||
use App\Console\Commands\Nuh;
|
||||
|
||||
class Services
|
||||
{
|
||||
public static function switch()
|
||||
{
|
||||
switch (Nuh::$options['name']) {
|
||||
case 'Txodds Markets':
|
||||
CallTxoddsMarkets::call();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Maintenance\Tasks;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Console\Commands\Xml;
|
||||
use App\Models\TxoddsMarket;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class CallTxoddsMarkets
|
||||
{
|
||||
public static function call()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('TxoddsMarkets', 'b');
|
||||
}
|
||||
|
||||
$url = 'https://xml2.txodds.com/feed/odds_types.php';
|
||||
|
||||
$data = Xml::load($url);
|
||||
|
||||
foreach ($data as $row) {
|
||||
|
||||
$market = [
|
||||
'shortname' => $row->sname,
|
||||
'name' => (string) $row->name,
|
||||
];
|
||||
|
||||
TxoddsMarket::updateOrCreate(['market_id' => (int) $row->ot], $market);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ use App\Console\Commands\Grapper\Betsapi;
|
||||
use App\Console\Commands\Grapper\Logifuture;
|
||||
use App\Console\Commands\Grapper\Magloo;
|
||||
use App\Console\Commands\Grapper\TxOdds;
|
||||
use App\Console\Commands\Maintenance\Services;
|
||||
use App\Console\Services\Service;
|
||||
use App\Models\Supervisor;
|
||||
use App\Utilities\Notice;
|
||||
use App\Utilities\Supervisorctl;
|
||||
@@ -24,7 +26,7 @@ class Nuh extends Command
|
||||
|
||||
public static $BETSAPI_TOKEN = '36152-aeTRNnZxSPUwGe';
|
||||
|
||||
protected $signature = 'nuh {process=help} {--id=0} {--f=} {--a} {--p} {--d} {--x} {--t} {--w} {--g} {--r} {--s} {--t} {--q}';
|
||||
protected $signature = 'nuh {process=help} {--id=0} {--f=} {--p} {--d} {--x} {--t} {--w} {--g} {--r} {--s} {--t} {--q}';
|
||||
|
||||
protected $description = 'Nuh';
|
||||
|
||||
@@ -41,11 +43,10 @@ class Nuh extends Command
|
||||
$txt .= '----------------------------------------------'.PHP_EOL;
|
||||
$txt .= 'process [id] (required)'.PHP_EOL;
|
||||
$txt .= '--id=matchid (optional) calling spezific id'.PHP_EOL;
|
||||
$txt .= '--f=name (optional) [bookmaker_sport]'.PHP_EOL;
|
||||
$txt .= '--f=name (optional) [bkms, markets]'.PHP_EOL;
|
||||
$txt .= '----------------------------------------------'.PHP_EOL.PHP_EOL;
|
||||
$txt .= 'Options'.PHP_EOL;
|
||||
$txt .= '----------------------------------------------'.PHP_EOL;
|
||||
$txt .= '--a reload all'.PHP_EOL;
|
||||
$txt .= '--p use proxy'.PHP_EOL;
|
||||
$txt .= '--d debug'.PHP_EOL;
|
||||
$txt .= '--x generate supervisors'.PHP_EOL;
|
||||
@@ -100,6 +101,10 @@ class Nuh extends Command
|
||||
// LOGIFUTUR COLOMBIA
|
||||
Logifuture::switch();
|
||||
break;
|
||||
case 7:
|
||||
// SERVICE
|
||||
Services::switch();
|
||||
break;
|
||||
default:
|
||||
Notice::note('Provider not defined', 'r', 1);
|
||||
break;
|
||||
|
||||
@@ -21,13 +21,13 @@ class SupervisorForm
|
||||
->relationship('sport', 'name')
|
||||
->nullable(),
|
||||
|
||||
TextInput::make('sleep')->default(15),
|
||||
TextInput::make('sleep')->default(30),
|
||||
TextInput::make('maxsconds')->label('Seconds till throwing an error')->default(1800),
|
||||
Section::make('Run processes paralell for speed')
|
||||
->description('Set start and end days if more processes grap the same data')
|
||||
->schema([
|
||||
TextInput::make('days_from')->columns(1),
|
||||
TextInput::make('days_to')->columns(1),
|
||||
TextInput::make('days_from')->columns(1)->default(0),
|
||||
TextInput::make('days_to')->columns(1)->default(1),
|
||||
])->columns(2)->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -33,13 +33,6 @@ class SupervisorResource extends Resource
|
||||
return SupervisorsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -34,14 +34,35 @@ class SupervisorsTable
|
||||
default => 'warning',
|
||||
}),
|
||||
SelectColumn::make('name')
|
||||
->options([
|
||||
'Fixtures' => 'Fixtures',
|
||||
'Odds' => 'Odds',
|
||||
'Willhill' => 'Willhill',
|
||||
'Bwin' => 'Bwin',
|
||||
'Bet365' => 'Bet365',
|
||||
'Betfair' => 'Betfair',
|
||||
]),
|
||||
->options(function ($record) {
|
||||
switch ($record->provider_id) {
|
||||
case 1:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
return [
|
||||
'Fixtures' => 'Fixtures',
|
||||
'Odds' => 'Odds',
|
||||
];
|
||||
case 2:
|
||||
return [
|
||||
'Fixtures' => 'Fixtures',
|
||||
'Odds' => 'Odds',
|
||||
'Willhill' => 'Willhill',
|
||||
'Bwin' => 'Bwin',
|
||||
'Bet365' => 'Bet365',
|
||||
'Betfair' => 'Betfair',
|
||||
];
|
||||
case 7:
|
||||
return [
|
||||
'Txodds Markets' => 'Txodds Markets',
|
||||
];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
|
||||
}),
|
||||
TextColumn::make('sport.name')->label('Sport'),
|
||||
TextColumn::make('days_from')->label('From'),
|
||||
TextColumn::make('days_to')->label('To'),
|
||||
@@ -50,9 +71,9 @@ class SupervisorsTable
|
||||
TextInputColumn::make('commandline_options')->width('2rem'),
|
||||
|
||||
// TextColumn::make('maxsconds')->label('Max Time'),
|
||||
// IconColumn::make('is_cron')->boolean()->label('Cron')->falseColor('gray'),
|
||||
// IconColumn::make('is_supervisor')->boolean()->label('Cron')->falseColor('gray'),
|
||||
ToggleColumn::make('use_lastcall')->label('Lastcall'),
|
||||
ToggleColumn::make('is_cron')->label('Cron'),
|
||||
ToggleColumn::make('is_supervisor')->label('Super')->tooltip('Create a supervisor process'),
|
||||
ToggleColumn::make('is_active')->label('Active'),
|
||||
])
|
||||
->filters([
|
||||
@@ -60,7 +81,7 @@ class SupervisorsTable
|
||||
->default(1)
|
||||
->relationship('provider', 'name')
|
||||
->label('Provider'),
|
||||
TernaryFilter::make('is_cron'),
|
||||
TernaryFilter::make('is_supervisor'),
|
||||
TernaryFilter::make('is_active'),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TxoddsMarkets\Pages;
|
||||
|
||||
use App\Filament\Resources\TxoddsMarkets\TxoddsMarketResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTxoddsMarket extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TxoddsMarketResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TxoddsMarkets\Pages;
|
||||
|
||||
use App\Filament\Resources\TxoddsMarkets\TxoddsMarketResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTxoddsMarket extends EditRecord
|
||||
{
|
||||
protected static string $resource = TxoddsMarketResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TxoddsMarkets\Pages;
|
||||
|
||||
use App\Filament\Resources\TxoddsMarkets\TxoddsMarketResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTxoddsMarkets extends ListRecords
|
||||
{
|
||||
protected static string $resource = TxoddsMarketResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TxoddsMarkets\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class TxoddsMarketForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TxoddsMarkets\Tables;
|
||||
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class TxoddsMarketsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('market_id')->badge()->searchable(),
|
||||
TextColumn::make('name')->searchable(),
|
||||
ToggleColumn::make('soccer')->toggleable(true),
|
||||
ToggleColumn::make('ice_hockey')->toggleable(true),
|
||||
ToggleColumn::make('basketball')->toggleable(true),
|
||||
ToggleColumn::make('tennis')->toggleable(true),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('sport_market')
|
||||
->schema([
|
||||
Select::make(name: 'sport_market')
|
||||
->placeholder('Filter Sport')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->preload()
|
||||
->options(function () {
|
||||
return [
|
||||
'soccer' => 'Soccer',
|
||||
'ice_hockey' => 'Ice Hockey',
|
||||
'basketball' => 'Basketball',
|
||||
'tennis' => 'Tennis',
|
||||
];
|
||||
})
|
||||
->live(),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['sport_market'],
|
||||
fn (Builder $query, $sport_market) => $query->where($sport_market, 1)
|
||||
);
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferColumnManager(false)
|
||||
->deferFilters(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\TxoddsMarkets;
|
||||
|
||||
use App\Filament\Clusters\Administrator\AdministratorCluster;
|
||||
use App\Filament\Resources\TxoddsMarkets\Pages\ListTxoddsMarkets;
|
||||
use App\Filament\Resources\TxoddsMarkets\Schemas\TxoddsMarketForm;
|
||||
use App\Filament\Resources\TxoddsMarkets\Tables\TxoddsMarketsTable;
|
||||
use App\Models\TxoddsMarket;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class TxoddsMarketResource extends Resource
|
||||
{
|
||||
protected static ?string $model = TxoddsMarket::class;
|
||||
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'phosphor-storefront';
|
||||
|
||||
protected static ?string $cluster = AdministratorCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 24;
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Grapper';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return TxoddsMarketForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return TxoddsMarketsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTxoddsMarkets::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class Supervisor extends Model
|
||||
'commandline_options',
|
||||
'maxsconds',
|
||||
'lastcall',
|
||||
'is_cron',
|
||||
'is_supervisor',
|
||||
'is_active',
|
||||
'days_from',
|
||||
'days_to',
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TxoddsMarket extends Model
|
||||
{
|
||||
protected $fillable = [
|
||||
'market_id',
|
||||
'shortname',
|
||||
'name',
|
||||
'soccer',
|
||||
'ice_hockey',
|
||||
'basketball',
|
||||
'tennis',
|
||||
];
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class Supervisorctl
|
||||
if (! $debug) {
|
||||
sleep($options['sleep']);
|
||||
} else {
|
||||
if ($options['is_cron']) {
|
||||
if ($options['is_supervisor']) {
|
||||
Notice::note('cron process timings set in crontab', 'b');
|
||||
} else {
|
||||
Notice::note('in production process sleeps for '.$options['sleep'].'sec', 'b');
|
||||
|
||||
Reference in new issue
Block a user