add PDOException on updated odds

This commit is contained in:
salam committed 2026-02-06 17:24:48 +01:00
1 parent b35c8c48e3
commit 980b716271
15 files changed
+270 -7

No files matched your search

@@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\Odds2way; use App\Models\Odds2way;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _2Way class _2Way
{ {
@@ -27,7 +28,25 @@ class _2Way
$res->a2w = $odds['a2w']; $res->a2w = $odds['a2w'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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);
} }
} }
} }
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\Odds2wayS1; use App\Models\Odds2wayS1;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _2WayS1 class _2WayS1
{ {
@@ -27,7 +28,24 @@ class _2WayS1
$res->a2w = $odds['a2w']; $res->a2w = $odds['a2w'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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);
} }
} }
} }
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\Odds3way; use App\Models\Odds3way;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _3Way class _3Way
{ {
@@ -24,12 +25,30 @@ class _3Way
if (! $res) { if (! $res) {
Odds3way::create($odds); Odds3way::create($odds);
} elseif (! $block_update) { } elseif (! $block_update) {
$res->h3w = $odds['h3w']; $res->h3w = $odds['h3w'];
$res->a3w = $odds['d3w']; $res->a3w = $odds['d3w'];
$res->d3w = $odds['a3w']; $res->d3w = $odds['a3w'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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);
} }
} }
} }
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\Odds3wayHt; use App\Models\Odds3wayHt;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _3WayHt class _3WayHt
{ {
@@ -29,7 +30,25 @@ class _3WayHt
$res->d3w = $odds['a3w']; $res->d3w = $odds['a3w'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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);
} }
} }
} }
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\OddsDc; use App\Models\OddsDc;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _Dc class _Dc
{ {
@@ -29,7 +30,25 @@ class _Dc
$res->dcx2 = $odds['dcx2']; $res->dcx2 = $odds['dcx2'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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);
} }
} }
} }
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\OddsDnb; use App\Models\OddsDnb;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _Dnb class _Dnb
{ {
@@ -27,7 +28,25 @@ class _Dnb
$res->dnb2 = $odds['dnb2']; $res->dnb2 = $odds['dnb2'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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);
} }
} }
} }
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\OddsGgng; use App\Models\OddsGgng;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _Ggng class _Ggng
{ {
@@ -27,7 +28,25 @@ class _Ggng
$res->ng = $odds['ng']; $res->ng = $odds['ng'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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);
} }
} }
} }
@@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\OddsPoint; use App\Models\OddsPoint;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _Points class _Points
{ {
@@ -39,7 +40,25 @@ class _Points
$res->away = $odds['away']; $res->away = $odds['away'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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'); ActiveSpread::collect($odds, 'odds_points');
@@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\OddsPointHt; use App\Models\OddsPointHt;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _PointsHt class _PointsHt
{ {
@@ -39,7 +40,25 @@ class _PointsHt
$res->away = $odds['away']; $res->away = $odds['away'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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'); ActiveSpread::collect($odds, 'odds_points_ht');
@@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\OddsPointQ1; use App\Models\OddsPointQ1;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _PointsQ1 class _PointsQ1
{ {
@@ -39,7 +40,25 @@ class _PointsQ1
$res->away = $odds['away']; $res->away = $odds['away'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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'); ActiveSpread::collect($odds, 'odds_points_q1');
@@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\OddsTotal; use App\Models\OddsTotal;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _Totals class _Totals
{ {
@@ -45,7 +46,25 @@ class _Totals
$res->under = $odds['under']; $res->under = $odds['under'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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'); ActiveSpread::collect($odds, 'odds_totals');
@@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\OddsTotalHt; use App\Models\OddsTotalHt;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _TotalsHt class _TotalsHt
{ {
@@ -45,7 +46,25 @@ class _TotalsHt
$res->under = $odds['under']; $res->under = $odds['under'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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'); ActiveSpread::collect($odds, 'odds_totals_ht');
@@ -6,6 +6,7 @@ use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\OddsTotalQ1; use App\Models\OddsTotalQ1;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _TotalsQ1 class _TotalsQ1
{ {
@@ -45,7 +46,25 @@ class _TotalsQ1
$res->under = $odds['under']; $res->under = $odds['under'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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'); ActiveSpread::collect($odds, 'odds_totals_q1');
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\OddsTq; use App\Models\OddsTq;
use App\Utilities\Margin; use App\Utilities\Margin;
use PDOException;
class _Tq class _Tq
{ {
@@ -27,7 +28,25 @@ class _Tq
$res->atq = $odds['atq']; $res->atq = $odds['atq'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$res->save(); $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);
} }
} }
} }
@@ -19,16 +19,14 @@ class TxoddsFlags
Notice::note('Txodds Markets Status', 'b'); Notice::note('Txodds Markets Status', 'b');
} }
if (Nuh::$options['lastcall'] >= strtotime('-1 hour')) { $lastcall = Nuh::$options['lastcall'] > time() - 600 ? '&last='.Nuh::$options['lastcall'] : '&last='.time() - 600;
Nuh::$options['lastcall'] = 0;
}
/** /**
* SOCCER * SOCCER
*/ */
$tables = OddsTable::where('soccer', 1)->pluck('name'); $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); $data = Xml::load($url);
@@ -43,16 +41,16 @@ class TxoddsFlags
*/ */
$tables = OddsTable::where('other', 1)->pluck('name'); $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); $data = Xml::load($url);
Supervisor::where('id', Nuh::$options['supervisor_id'])->update(['lastcall' => (int) $data['timestamp']]);
foreach ($data as $row) { foreach ($data as $row) {
foreach ($tables as $table) { foreach ($tables as $table) {
DB::table($table)->where('offer_id', (int) $row['id'])->update(['last_updated' => $row['last_updated'], 'flags' => $row['flags']]); 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()]);
} }
} }