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
@@ -13,7 +13,6 @@ use App\Models\OddsDnb;
|
||||
use App\Models\OddsGgng;
|
||||
use App\Models\OddsTotal;
|
||||
use App\Models\Sport;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -74,11 +73,13 @@ class Bet365
|
||||
|
||||
if (isset($data['results'][0]['main'])) {
|
||||
|
||||
EventBookmaker::updateOrCreate([
|
||||
'event_id' => $event->id,
|
||||
'sport_id' => $event->sport_id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
], ['starttime' => $event->starttime, 'in_feed' => 1, 'bmoid' => $event->bet365_id]);
|
||||
DB::transaction(function () use ($event) {
|
||||
EventBookmaker::updateOrCreate([
|
||||
'event_id' => $event->id,
|
||||
'sport_id' => $event->sport_id,
|
||||
'bookmaker_id' => $bookmaker_id,
|
||||
], ['starttime' => $event->starttime, 'in_feed' => 1, 'bmoid' => $event->bet365_id]);
|
||||
}, 5);
|
||||
|
||||
$offer = $data['results'][0]['main']['sp'];
|
||||
|
||||
@@ -119,9 +120,9 @@ class Bet365
|
||||
$res->d3w = $odds['a3w'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,8 +156,9 @@ class Bet365
|
||||
$res->dcx2 = $odds['dcx2'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -198,8 +200,9 @@ class Bet365
|
||||
$res->difference = abs(1 / $odds['over'] - 1 / $odds['under']);
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -233,9 +236,9 @@ class Bet365
|
||||
$res->ng = $odds['ng'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,8 +270,9 @@ class Bet365
|
||||
$res->dnb2 = $odds['dnb2'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -303,8 +307,9 @@ class Bet365
|
||||
$res->a3w = $odds['a3w'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ use App\Console\Commands\Nuh;
|
||||
use App\Models\Event;
|
||||
use App\Models\Odds3way;
|
||||
use App\Models\Supervisor;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Carbon;
|
||||
@@ -99,8 +98,9 @@ class Odds
|
||||
$res->a3w = $odds['a3w'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
break;
|
||||
@@ -126,8 +126,9 @@ class Odds
|
||||
$res->a3w = $odds['a3w'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -101,7 +101,9 @@ class FindFixture
|
||||
}
|
||||
|
||||
if ($update_array) {
|
||||
Event::where('id', $match->id)->update($update_array);
|
||||
DB::transaction(function () use ($match) {
|
||||
Event::where('id', $match->id)->update($update_array);
|
||||
}, 5);
|
||||
}
|
||||
|
||||
if (! in_array(Nuh::$options['provider_id'], [5, 6, 9])) {
|
||||
@@ -149,6 +151,8 @@ class FindFixture
|
||||
|
||||
if ($match_id) {
|
||||
|
||||
$event['id'] = $match_id;
|
||||
|
||||
$update_array = [];
|
||||
|
||||
if ($betradar_id) {
|
||||
|
||||
@@ -15,7 +15,6 @@ use App\Models\EventBookmaker;
|
||||
use App\Models\Sport;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use PDOException;
|
||||
|
||||
class Logifuture
|
||||
{
|
||||
@@ -26,6 +25,7 @@ class Logifuture
|
||||
public static function switch()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$echo_data = Nuh::$options['e'] ?? 0;
|
||||
|
||||
$sportmap = Sport::map('logi', 1, [Nuh::$options['sport_id']]);
|
||||
@@ -42,6 +42,8 @@ class Logifuture
|
||||
|
||||
$matches = LogifutureData::load($logifuture_sport_id);
|
||||
|
||||
// Notice::note($matches, 'b');
|
||||
|
||||
if ($echo_data) {
|
||||
Notice::note($matches, 'g');
|
||||
}
|
||||
@@ -54,38 +56,27 @@ class Logifuture
|
||||
|
||||
foreach ($matches as $match) {
|
||||
|
||||
// Notice::note($match, 'r');
|
||||
|
||||
if (strpos($match['sportCategory'], 'Simulated Reality') === false) {
|
||||
|
||||
$event = MapEvent::filter($sport_id, $match);
|
||||
|
||||
FindFixture::find($event);
|
||||
|
||||
Notice::note($event, 'r');
|
||||
|
||||
if (isset($event['id'])) {
|
||||
|
||||
Notice::note($event, 'b');
|
||||
|
||||
$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'], 'startime' => $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);
|
||||
EventBookmaker::updateOrCreate([
|
||||
'event_id' => $event['id'],
|
||||
'sport_id' => $sport_id,
|
||||
'bookmaker_id' => Nuh::$options['bookmaker_id'],
|
||||
], ['in_feed' => 1, 'bmoid' => $event['id'], 'startime' => $event['starttime']]);
|
||||
|
||||
switch ($sport_id) {
|
||||
case 1:
|
||||
@@ -106,31 +97,12 @@ class Logifuture
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if ($event_id_collector) {
|
||||
$max_tries = 5;
|
||||
$tries = 0;
|
||||
do {
|
||||
$retry = false;
|
||||
try {
|
||||
|
||||
$handle = EventBookmaker::whereNotIn('event_id', $event_id_collector)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->update(['in_feed' => 0]);
|
||||
|
||||
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);
|
||||
EventBookmaker::whereNotIn('event_id', $event_id_collector)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->update(['in_feed' => 0]);
|
||||
|
||||
$tables = ['odds_2ways', 'odds_2ways_s1', 'odds_3ways', 'odds_totals', 'odds_points', 'odds_ggng', 'odds_dc', 'odds_tq', 'odds_points_q1', 'odds_totals_q1'];
|
||||
foreach ($tables as $table) {
|
||||
|
||||
@@ -101,7 +101,9 @@ class Icehockey
|
||||
$res->a3w = number_format($_3way['a3w'], 2);
|
||||
$res->flags = 1;
|
||||
$res->margin = $_3way['margin'];
|
||||
$res->save();
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +123,9 @@ class Icehockey
|
||||
$res->a2w = number_format($ml['a2w'], 2);
|
||||
$res->flags = 1;
|
||||
$res->margin = $ml['margin'];
|
||||
$res->save();
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +144,9 @@ class Icehockey
|
||||
$res->a2w = number_format($ml['a2w'], 2);
|
||||
$res->flags = 1;
|
||||
$res->margin = $mls1['margin'];
|
||||
$res->save();
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ use App\Models\OddsDc;
|
||||
use App\Models\OddsGgng;
|
||||
use App\Models\OddsTotal;
|
||||
use App\Models\OddsTq;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class Soccer
|
||||
@@ -94,8 +93,9 @@ class Soccer
|
||||
$res->a3w = number_format($_3way['a3w'], 2);
|
||||
$res->flags = 1;
|
||||
$res->margin = $_3way['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -120,8 +120,9 @@ class Soccer
|
||||
$res->under = number_format($_total['under'], 2);
|
||||
$res->flags = 1;
|
||||
$res->margin = $_total['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -141,8 +142,9 @@ class Soccer
|
||||
$res->ng = number_format($_ggng['ng'], 2);
|
||||
$res->flags = 1;
|
||||
$res->margin = $_ggng['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,8 +165,9 @@ class Soccer
|
||||
$res->dcx2 = number_format($_dc['dcx2'], 2);
|
||||
$res->flags = 1;
|
||||
$res->margin = $_dc['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,8 +187,9 @@ class Soccer
|
||||
$res->atq = number_format($_tq['atq'], 2);
|
||||
$res->flags = 1;
|
||||
$res->margin = $_tq['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ use App\Console\Commands\Grapper\Logifuture\Tools\LogifutureStoreTotals;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\Odds2way;
|
||||
use App\Models\Odds2wayS1;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class Tennis
|
||||
{
|
||||
@@ -76,6 +76,8 @@ class Tennis
|
||||
|
||||
$ml = array_merge($ml, $base);
|
||||
|
||||
// Notice::note($ml, 'g');
|
||||
|
||||
$res = Odds2way::where('event_id', $event['id'])->where('bookmaker_id', $event['bookmaker_id'])->first();
|
||||
|
||||
if (! $res) {
|
||||
@@ -85,8 +87,9 @@ class Tennis
|
||||
$res->a2w = number_format($ml['a2w'], 2);
|
||||
$res->flags = 1;
|
||||
$res->margin = $ml['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -106,8 +109,9 @@ class Tennis
|
||||
$res->a2w = number_format($ml['a2w'], 2);
|
||||
$res->flags = 1;
|
||||
$res->margin = $mls1['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Console\Commands\Grapper\Logifuture\Tools;
|
||||
|
||||
use App\Models\OddsPoint;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class LogifutureStorePoints
|
||||
@@ -40,8 +39,9 @@ class LogifutureStorePoints
|
||||
$res->difference = $odds['difference'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Console\Commands\Grapper\Logifuture\Tools;
|
||||
|
||||
use App\Models\OddsPointQ1;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class LogifutureStorePointsQ1
|
||||
@@ -40,8 +39,9 @@ class LogifutureStorePointsQ1
|
||||
$res->difference = $odds['difference'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Console\Commands\Grapper\Logifuture\Tools;
|
||||
|
||||
use App\Models\OddsTotal;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class LogifutureStoreTotals
|
||||
@@ -40,8 +39,9 @@ class LogifutureStoreTotals
|
||||
$res->difference = $odds['difference'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Console\Commands\Grapper\Logifuture\Tools;
|
||||
|
||||
use App\Models\OddsTotalQ1;
|
||||
use App\Utilities\DatabaseFunctions;
|
||||
use App\Utilities\Margin;
|
||||
|
||||
class LogifutureStoreTotalsQ1
|
||||
@@ -40,8 +39,9 @@ class LogifutureStoreTotalsQ1
|
||||
$res->difference = $odds['difference'];
|
||||
$res->flags = 1;
|
||||
$res->margin = $odds['margin'];
|
||||
|
||||
DatabaseFunctions::save_update($res);
|
||||
DB::transaction(function () use ($res) {
|
||||
$res->save();
|
||||
}, 5);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Console\Commands\Services\Tasks\Alarm;
|
||||
|
||||
use App\Models\EventBookmaker;
|
||||
use PDOException;
|
||||
|
||||
class AlarmStore
|
||||
{
|
||||
@@ -43,23 +42,6 @@ class AlarmStore
|
||||
}
|
||||
}
|
||||
|
||||
$max_tries = 5;
|
||||
$tries = 0;
|
||||
do {
|
||||
$retry = false;
|
||||
try {
|
||||
|
||||
$res = EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $client_bookmaker_id)->update($update_array);
|
||||
|
||||
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);
|
||||
EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $client_bookmaker_id)->update($update_array);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
use PDOException;
|
||||
|
||||
class DatabaseFunctions
|
||||
{
|
||||
public static function save_update($query)
|
||||
@@ -12,12 +10,13 @@ class DatabaseFunctions
|
||||
$tries = 0;
|
||||
do {
|
||||
$retry = false;
|
||||
$tries++;
|
||||
try {
|
||||
|
||||
$query->save();
|
||||
|
||||
return $query;
|
||||
} catch (PDOException $exc) {
|
||||
} catch (\PDOException $exc) {
|
||||
if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) {
|
||||
$retry = true;
|
||||
sleep(1);
|
||||
|
||||
Reference in new issue
Block a user