add DB::transaction to catch looked query
This commit is contained in:
1 parent
f1b0f43ded
commit
65dc70e681
38 files changed
+218
-266
No files matched your search
@@ -9,7 +9,6 @@ use App\Models\EventBookmaker;
|
||||
use App\Models\Sport;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
use PDOException;
|
||||
|
||||
class Fixtures
|
||||
{
|
||||
@@ -101,33 +100,12 @@ class Fixtures
|
||||
|
||||
FindFixture::find($event);
|
||||
|
||||
if (isset($event['id'])) {
|
||||
EventBookmaker::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'sport_id' => $sport_id,
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'starttime' => $event['starttime']]);
|
||||
|
||||
$event_id_collector[] = $event['id'];
|
||||
|
||||
$max_tries = 5;
|
||||
$tries = 0;
|
||||
do {
|
||||
$retry = false;
|
||||
try {
|
||||
$handle = EventBookmaker::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'sport_id' => $sport_id,
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'starttime' => $event['starttime']]);
|
||||
|
||||
return $handle;
|
||||
} catch (PDOException $exc) {
|
||||
if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) {
|
||||
$retry = true;
|
||||
sleep(1);
|
||||
} else {
|
||||
throw $exc;
|
||||
}
|
||||
}
|
||||
} while ($retry);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\Odds3way;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MaglooStore1x2
|
||||
{
|
||||
@@ -27,8 +27,9 @@ class MaglooStore1x2
|
||||
$res->a3w = $odds['a3w'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsDc;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MaglooStoreDc
|
||||
{
|
||||
@@ -28,8 +28,9 @@ class MaglooStoreDc
|
||||
$res->dcx2 = $odds['dcx2'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsGgng;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MaglooStoreGgng
|
||||
{
|
||||
@@ -26,8 +26,9 @@ class MaglooStoreGgng
|
||||
$res->ng = $odds['ng'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsPoint;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MaglooStorePoints
|
||||
{
|
||||
@@ -37,8 +37,9 @@ class MaglooStorePoints
|
||||
$res->active_spread = $odds['active_spread'];
|
||||
$res->difference = $odds['difference'];
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsPointQ1;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MaglooStorePointsQ1
|
||||
{
|
||||
@@ -37,8 +37,9 @@ class MaglooStorePointsQ1
|
||||
$res->active_spread = $odds['active_spread'];
|
||||
$res->difference = $odds['difference'];
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsTotal;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MaglooStoreTotals
|
||||
{
|
||||
@@ -37,8 +37,9 @@ class MaglooStoreTotals
|
||||
$res->active_spread = $odds['active_spread'];
|
||||
$res->difference = $odds['difference'];
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsTotalQ1;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MaglooStoreTotalsQ1
|
||||
{
|
||||
@@ -37,8 +37,9 @@ class MaglooStoreTotalsQ1
|
||||
$res->active_spread = $odds['active_spread'];
|
||||
$res->difference = $odds['difference'];
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Console\Commands\Grapper\Magloo\Odds;
|
||||
|
||||
use App\Models\OddsTq;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MaglooStoreTq
|
||||
{
|
||||
@@ -26,8 +26,9 @@ class MaglooStoreTq
|
||||
$res->htq = $odds['htq'];
|
||||
$res->atq = $odds['atq'];
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user