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
+284 -21

No files matched your search

@@ -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');