From 980b7162713bc8041c544b89288915fa4929d236 Mon Sep 17 00:00:00 2001 From: salam Date: Fri, 6 Feb 2026 17:24:48 +0100 Subject: [PATCH] add PDOException on updated odds --- .../Commands/Grapper/TxOdds/Odds/_2Way.php | 21 ++++++++++++++++++- .../Commands/Grapper/TxOdds/Odds/_2WayS1.php | 20 +++++++++++++++++- .../Commands/Grapper/TxOdds/Odds/_3Way.php | 21 ++++++++++++++++++- .../Commands/Grapper/TxOdds/Odds/_3WayHt.php | 21 ++++++++++++++++++- .../Commands/Grapper/TxOdds/Odds/_Dc.php | 21 ++++++++++++++++++- .../Commands/Grapper/TxOdds/Odds/_Dnb.php | 21 ++++++++++++++++++- .../Commands/Grapper/TxOdds/Odds/_Ggng.php | 21 ++++++++++++++++++- .../Commands/Grapper/TxOdds/Odds/_Points.php | 21 ++++++++++++++++++- .../Grapper/TxOdds/Odds/_PointsHt.php | 21 ++++++++++++++++++- .../Grapper/TxOdds/Odds/_PointsQ1.php | 21 ++++++++++++++++++- .../Commands/Grapper/TxOdds/Odds/_Totals.php | 21 ++++++++++++++++++- .../Grapper/TxOdds/Odds/_TotalsHt.php | 21 ++++++++++++++++++- .../Grapper/TxOdds/Odds/_TotalsQ1.php | 21 ++++++++++++++++++- .../Commands/Grapper/TxOdds/Odds/_Tq.php | 21 ++++++++++++++++++- .../Commands/Services/Tasks/TxoddsFlags.php | 12 +++++------ 15 files changed, 284 insertions(+), 21 deletions(-) diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_2Way.php b/app/Console/Commands/Grapper/TxOdds/Odds/_2Way.php index 97b65aa1..618840e4 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_2Way.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_2Way.php @@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds; use App\Console\Commands\Nuh; use App\Models\Odds2way; use App\Utilities\Margin; +use PDOException; class _2Way { @@ -27,7 +28,25 @@ class _2Way $res->a2w = $odds['a2w']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } } } diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_2WayS1.php b/app/Console/Commands/Grapper/TxOdds/Odds/_2WayS1.php index 79ddc7c0..6a9ff6fb 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_2WayS1.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_2WayS1.php @@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds; use App\Console\Commands\Nuh; use App\Models\Odds2wayS1; use App\Utilities\Margin; +use PDOException; class _2WayS1 { @@ -27,7 +28,24 @@ class _2WayS1 $res->a2w = $odds['a2w']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } } } diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_3Way.php b/app/Console/Commands/Grapper/TxOdds/Odds/_3Way.php index 7cb6c15d..0edf2bba 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_3Way.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_3Way.php @@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds; use App\Console\Commands\Nuh; use App\Models\Odds3way; use App\Utilities\Margin; +use PDOException; class _3Way { @@ -24,12 +25,30 @@ class _3Way if (! $res) { Odds3way::create($odds); } elseif (! $block_update) { + $res->h3w = $odds['h3w']; $res->a3w = $odds['d3w']; $res->d3w = $odds['a3w']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } } } diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_3WayHt.php b/app/Console/Commands/Grapper/TxOdds/Odds/_3WayHt.php index 056a4ad0..5b7adcdf 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_3WayHt.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_3WayHt.php @@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds; use App\Console\Commands\Nuh; use App\Models\Odds3wayHt; use App\Utilities\Margin; +use PDOException; class _3WayHt { @@ -29,7 +30,25 @@ class _3WayHt $res->d3w = $odds['a3w']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } } } diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_Dc.php b/app/Console/Commands/Grapper/TxOdds/Odds/_Dc.php index 1e0181fd..06df01d7 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_Dc.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_Dc.php @@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds; use App\Console\Commands\Nuh; use App\Models\OddsDc; use App\Utilities\Margin; +use PDOException; class _Dc { @@ -29,7 +30,25 @@ class _Dc $res->dcx2 = $odds['dcx2']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } } } diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_Dnb.php b/app/Console/Commands/Grapper/TxOdds/Odds/_Dnb.php index ebd71d40..cffd803b 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_Dnb.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_Dnb.php @@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds; use App\Console\Commands\Nuh; use App\Models\OddsDnb; use App\Utilities\Margin; +use PDOException; class _Dnb { @@ -27,7 +28,25 @@ class _Dnb $res->dnb2 = $odds['dnb2']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } } } diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_Ggng.php b/app/Console/Commands/Grapper/TxOdds/Odds/_Ggng.php index c43d6f03..c49000da 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_Ggng.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_Ggng.php @@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds; use App\Console\Commands\Nuh; use App\Models\OddsGgng; use App\Utilities\Margin; +use PDOException; class _Ggng { @@ -27,7 +28,25 @@ class _Ggng $res->ng = $odds['ng']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } } } diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_Points.php b/app/Console/Commands/Grapper/TxOdds/Odds/_Points.php index 751ff5c6..1fc85386 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_Points.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_Points.php @@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread; use App\Console\Commands\Nuh; use App\Models\OddsPoint; use App\Utilities\Margin; +use PDOException; class _Points { @@ -39,7 +40,25 @@ class _Points $res->away = $odds['away']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + $max_tries = 5; + $tries = 0; + + do { + $retry = false; + try { + + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } ActiveSpread::collect($odds, 'odds_points'); diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_PointsHt.php b/app/Console/Commands/Grapper/TxOdds/Odds/_PointsHt.php index e80207fe..c66649ec 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_PointsHt.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_PointsHt.php @@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread; use App\Console\Commands\Nuh; use App\Models\OddsPointHt; use App\Utilities\Margin; +use PDOException; class _PointsHt { @@ -39,7 +40,25 @@ class _PointsHt $res->away = $odds['away']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } ActiveSpread::collect($odds, 'odds_points_ht'); diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_PointsQ1.php b/app/Console/Commands/Grapper/TxOdds/Odds/_PointsQ1.php index 07736d56..7b2570f2 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_PointsQ1.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_PointsQ1.php @@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread; use App\Console\Commands\Nuh; use App\Models\OddsPointQ1; use App\Utilities\Margin; +use PDOException; class _PointsQ1 { @@ -39,7 +40,25 @@ class _PointsQ1 $res->away = $odds['away']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } ActiveSpread::collect($odds, 'odds_points_q1'); diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_Totals.php b/app/Console/Commands/Grapper/TxOdds/Odds/_Totals.php index 53642770..f66ebb5c 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_Totals.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_Totals.php @@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread; use App\Console\Commands\Nuh; use App\Models\OddsTotal; use App\Utilities\Margin; +use PDOException; class _Totals { @@ -45,7 +46,25 @@ class _Totals $res->under = $odds['under']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } ActiveSpread::collect($odds, 'odds_totals'); diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsHt.php b/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsHt.php index cd1864d7..2d46da6f 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsHt.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsHt.php @@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread; use App\Console\Commands\Nuh; use App\Models\OddsTotalHt; use App\Utilities\Margin; +use PDOException; class _TotalsHt { @@ -45,7 +46,25 @@ class _TotalsHt $res->under = $odds['under']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } ActiveSpread::collect($odds, 'odds_totals_ht'); diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsQ1.php b/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsQ1.php index 9e9a1528..8c185b2c 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsQ1.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsQ1.php @@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread; use App\Console\Commands\Nuh; use App\Models\OddsTotalQ1; use App\Utilities\Margin; +use PDOException; class _TotalsQ1 { @@ -45,7 +46,25 @@ class _TotalsQ1 $res->under = $odds['under']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } ActiveSpread::collect($odds, 'odds_totals_q1'); diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_Tq.php b/app/Console/Commands/Grapper/TxOdds/Odds/_Tq.php index c25f5488..0d4b0c20 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_Tq.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_Tq.php @@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds; use App\Console\Commands\Nuh; use App\Models\OddsTq; use App\Utilities\Margin; +use PDOException; class _Tq { @@ -27,7 +28,25 @@ class _Tq $res->atq = $odds['atq']; $res->flags = 1; $res->margin = $odds['margin']; - $res->save(); + + $max_tries = 5; + $tries = 0; + do { + $retry = false; + try { + + $res->save(); + + return $res; + } catch (PDOException $exc) { + if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { + $retry = true; + sleep(1); + } else { + throw $exc; + } + } + } while ($retry); } } } diff --git a/app/Console/Commands/Services/Tasks/TxoddsFlags.php b/app/Console/Commands/Services/Tasks/TxoddsFlags.php index c6988916..12b22712 100644 --- a/app/Console/Commands/Services/Tasks/TxoddsFlags.php +++ b/app/Console/Commands/Services/Tasks/TxoddsFlags.php @@ -19,16 +19,14 @@ class TxoddsFlags Notice::note('Txodds Markets Status', 'b'); } - if (Nuh::$options['lastcall'] >= strtotime('-1 hour')) { - Nuh::$options['lastcall'] = 0; - } + $lastcall = Nuh::$options['lastcall'] > time() - 600 ? '&last='.Nuh::$options['lastcall'] : '&last='.time() - 600; /** * SOCCER */ $tables = OddsTable::where('soccer', 1)->pluck('name'); - $url = 'https://xml2.txodds.com/feed/boid_states.php?ident=betaid1&passwd=Dy59vpRC&last='.Nuh::$options['lastcall']; + $url = 'https://xml2.txodds.com/feed/boid_states.php?ident=betaid1&passwd=Dy59vpRC'.$lastcall; $data = Xml::load($url); @@ -43,16 +41,16 @@ class TxoddsFlags */ $tables = OddsTable::where('other', 1)->pluck('name'); - $url = 'https://xml2.txodds.com/feed/boid_states.php?ident=betaid2&passwd=Dy59vpRC&last='.Nuh::$options['lastcall']; + $url = 'https://xml2.txodds.com/feed/boid_states.php?ident=betaid2&passwd=Dy59vpRC'.$lastcall; $data = Xml::load($url); + Supervisor::where('id', Nuh::$options['supervisor_id'])->update(['lastcall' => (int) $data['timestamp']]); + foreach ($data as $row) { foreach ($tables as $table) { DB::table($table)->where('offer_id', (int) $row['id'])->update(['last_updated' => $row['last_updated'], 'flags' => $row['flags']]); } } - - Supervisor::where('id', Nuh::$options['supervisor_id'])->update(['lastcall' => time()]); } }