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
@@ -27,9 +27,9 @@ use App\Models\EventBookmaker;
|
||||
use App\Models\Group;
|
||||
use App\Models\Supervisor;
|
||||
use App\Models\TxoddsMarket;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Odds
|
||||
{
|
||||
@@ -238,10 +238,10 @@ class Odds
|
||||
'competition_group_id' => (int) $row->group['cgid'],
|
||||
];
|
||||
|
||||
$res = Event::updateOrCreate(['id' => (int) $row['id']], $event);
|
||||
if ($res) {
|
||||
$event_id = $res->id;
|
||||
}
|
||||
$res = DB::transaction(function () use ($row, $event) {
|
||||
return Event::updateOrCreate(['id' => (int) $row['id']], $event);
|
||||
}, 5);
|
||||
$event_id = $res->id;
|
||||
|
||||
$group = [
|
||||
'competition_group_id' => (string) $row->group['cgid'],
|
||||
@@ -326,7 +326,10 @@ class Odds
|
||||
$res = EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->first();
|
||||
if ($res && $res->starttime != $attributeValue) {
|
||||
$res->starttime = $attributeValue;
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -342,13 +345,16 @@ class Odds
|
||||
$res = EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->first();
|
||||
if ($res && $res->starttime != $attributeValue) {
|
||||
$res->starttime = $attributeValue;
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_2Way::grap($odds, $offer);
|
||||
|
||||
break;
|
||||
case 3:
|
||||
foreach ($offer->odds->attributes() as $attributeName => $attributeValue) {
|
||||
@@ -358,7 +364,9 @@ class Odds
|
||||
$res = EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->first();
|
||||
if ($res && $res->starttime != $attributeValue) {
|
||||
$res->starttime = $attributeValue;
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Console\Commands\Grapper\TxOdds\Odds\Tools;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use PDOException;
|
||||
|
||||
class ActiveSpread
|
||||
{
|
||||
@@ -41,49 +40,17 @@ class ActiveSpread
|
||||
DB::table($table)->where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->update(['active_spread' => 0]);
|
||||
|
||||
if (in_array($table, ['odds_points', 'odds_points_ht', 'odds_points_q1'])) {
|
||||
$max_tries = 5;
|
||||
$tries = 0;
|
||||
do {
|
||||
$retry = false;
|
||||
try {
|
||||
$query = DB::table($table)
|
||||
->where('event_id', $event_id)
|
||||
->where('bookmaker_id', $bookmaker_id)
|
||||
->where('handicap', (float) $value['active_spread'])
|
||||
->update(['active_spread' => 1]);
|
||||
|
||||
return $query;
|
||||
} catch (PDOException $exc) {
|
||||
if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) {
|
||||
$retry = true;
|
||||
sleep(1);
|
||||
} else {
|
||||
throw $exc;
|
||||
}
|
||||
}
|
||||
} while ($retry);
|
||||
DB::table($table)
|
||||
->where('event_id', $event_id)
|
||||
->where('bookmaker_id', $bookmaker_id)
|
||||
->where('handicap', (float) $value['active_spread'])
|
||||
->update(['active_spread' => 1]);
|
||||
} else {
|
||||
$max_tries = 5;
|
||||
$tries = 0;
|
||||
do {
|
||||
$retry = false;
|
||||
try {
|
||||
$query = DB::table($table)
|
||||
->where('event_id', $event_id)
|
||||
->where('bookmaker_id', $bookmaker_id)
|
||||
->where('total', (float) $value['active_spread'])
|
||||
->update(['active_spread' => 1]);
|
||||
|
||||
return $query;
|
||||
} catch (PDOException $exc) {
|
||||
if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) {
|
||||
$retry = true;
|
||||
sleep(1);
|
||||
} else {
|
||||
throw $exc;
|
||||
}
|
||||
}
|
||||
} while ($retry);
|
||||
DB::table($table)
|
||||
->where('event_id', $event_id)
|
||||
->where('bookmaker_id', $bookmaker_id)
|
||||
->where('total', (float) $value['active_spread'])
|
||||
->update(['active_spread' => 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Odds2way;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _2Way
|
||||
{
|
||||
@@ -29,8 +29,9 @@ class _2Way
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Odds2wayS1;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _2WayS1
|
||||
{
|
||||
@@ -28,8 +28,9 @@ class _2WayS1
|
||||
$res->a2w = $odds['a2w'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Odds3way;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _3Way
|
||||
{
|
||||
@@ -31,8 +31,9 @@ class _3Way
|
||||
$res->a3w = $odds['a3w'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Odds3wayHt;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _3WayHt
|
||||
{
|
||||
@@ -30,8 +30,9 @@ class _3WayHt
|
||||
$res->a3w = $odds['a3w'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\OddsDc;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _Dc
|
||||
{
|
||||
@@ -30,8 +30,9 @@ class _Dc
|
||||
$res->dcx2 = $odds['dcx2'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\OddsDnb;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _Dnb
|
||||
{
|
||||
@@ -28,8 +28,9 @@ class _Dnb
|
||||
$res->dnb2 = $odds['dnb2'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\OddsGgng;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _Ggng
|
||||
{
|
||||
@@ -28,8 +28,9 @@ class _Ggng
|
||||
$res->ng = $odds['ng'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\OddsPoint;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _Points
|
||||
{
|
||||
@@ -40,8 +40,9 @@ class _Points
|
||||
$res->away = $odds['away'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\OddsPointHt;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _PointsHt
|
||||
{
|
||||
@@ -40,8 +40,9 @@ class _PointsHt
|
||||
$res->away = $odds['away'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\OddsPointQ1;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _PointsQ1
|
||||
{
|
||||
@@ -40,8 +40,9 @@ class _PointsQ1
|
||||
$res->away = $odds['away'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\OddsTotal;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _Totals
|
||||
{
|
||||
@@ -46,8 +46,9 @@ class _Totals
|
||||
$res->under = $odds['under'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\OddsTotalHt;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _TotalsHt
|
||||
{
|
||||
@@ -46,8 +46,9 @@ class _TotalsHt
|
||||
$res->under = $odds['under'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
use App\Console\Commands\Grapper\TxOdds\Odds\Tools\ActiveSpread;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\OddsTotalQ1;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _TotalsQ1
|
||||
{
|
||||
@@ -46,8 +46,9 @@ class _TotalsQ1
|
||||
$res->under = $odds['under'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\OddsTq;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _Tq
|
||||
{
|
||||
@@ -28,8 +28,9 @@ class _Tq
|
||||
$res->atq = $odds['atq'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user