add DB::transaction to catch looked query

This commit is contained in:
salam committed 2026-02-16 10:02:07 +01:00
1 parent f1b0f43ded
commit 65dc70e681
38 files changed
+193 -241

No files matched your search

+20 -15
View File
@@ -13,7 +13,6 @@ use App\Models\OddsDnb;
use App\Models\OddsGgng; use App\Models\OddsGgng;
use App\Models\OddsTotal; use App\Models\OddsTotal;
use App\Models\Sport; use App\Models\Sport;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use App\Utilities\Notice; use App\Utilities\Notice;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
@@ -74,11 +73,13 @@ class Bet365
if (isset($data['results'][0]['main'])) { if (isset($data['results'][0]['main'])) {
DB::transaction(function () use ($event) {
EventBookmaker::updateOrCreate([ EventBookmaker::updateOrCreate([
'event_id' => $event->id, 'event_id' => $event->id,
'sport_id' => $event->sport_id, 'sport_id' => $event->sport_id,
'bookmaker_id' => $bookmaker_id, 'bookmaker_id' => $bookmaker_id,
], ['starttime' => $event->starttime, 'in_feed' => 1, 'bmoid' => $event->bet365_id]); ], ['starttime' => $event->starttime, 'in_feed' => 1, 'bmoid' => $event->bet365_id]);
}, 5);
$offer = $data['results'][0]['main']['sp']; $offer = $data['results'][0]['main']['sp'];
@@ -119,9 +120,9 @@ class Bet365
$res->d3w = $odds['a3w']; $res->d3w = $odds['a3w'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
} }
@@ -155,8 +156,9 @@ class Bet365
$res->dcx2 = $odds['dcx2']; $res->dcx2 = $odds['dcx2'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -198,8 +200,9 @@ class Bet365
$res->difference = abs(1 / $odds['over'] - 1 / $odds['under']); $res->difference = abs(1 / $odds['over'] - 1 / $odds['under']);
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -233,9 +236,9 @@ class Bet365
$res->ng = $odds['ng']; $res->ng = $odds['ng'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
} }
@@ -267,8 +270,9 @@ class Bet365
$res->dnb2 = $odds['dnb2']; $res->dnb2 = $odds['dnb2'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -303,8 +307,9 @@ class Bet365
$res->a3w = $odds['a3w']; $res->a3w = $odds['a3w'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -7,7 +7,6 @@ use App\Console\Commands\Nuh;
use App\Models\Event; use App\Models\Event;
use App\Models\Odds3way; use App\Models\Odds3way;
use App\Models\Supervisor; use App\Models\Supervisor;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use App\Utilities\Notice; use App\Utilities\Notice;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
@@ -99,8 +98,9 @@ class Odds
$res->a3w = $odds['a3w']; $res->a3w = $odds['a3w'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
break; break;
@@ -126,8 +126,9 @@ class Odds
$res->a3w = $odds['a3w']; $res->a3w = $odds['a3w'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
break; break;
@@ -101,7 +101,9 @@ class FindFixture
} }
if ($update_array) { if ($update_array) {
DB::transaction(function () use ($match) {
Event::where('id', $match->id)->update($update_array); Event::where('id', $match->id)->update($update_array);
}, 5);
} }
if (! in_array(Nuh::$options['provider_id'], [5, 6, 9])) { if (! in_array(Nuh::$options['provider_id'], [5, 6, 9])) {
@@ -149,6 +151,8 @@ class FindFixture
if ($match_id) { if ($match_id) {
$event['id'] = $match_id;
$update_array = []; $update_array = [];
if ($betradar_id) { if ($betradar_id) {
+12 -40
View File
@@ -15,7 +15,6 @@ use App\Models\EventBookmaker;
use App\Models\Sport; use App\Models\Sport;
use App\Utilities\Notice; use App\Utilities\Notice;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use PDOException;
class Logifuture class Logifuture
{ {
@@ -26,6 +25,7 @@ class Logifuture
public static function switch() public static function switch()
{ {
$debug = Nuh::$options['d'] ?? 0; $debug = Nuh::$options['d'] ?? 0;
$echo_data = Nuh::$options['e'] ?? 0; $echo_data = Nuh::$options['e'] ?? 0;
$sportmap = Sport::map('logi', 1, [Nuh::$options['sport_id']]); $sportmap = Sport::map('logi', 1, [Nuh::$options['sport_id']]);
@@ -42,6 +42,8 @@ class Logifuture
$matches = LogifutureData::load($logifuture_sport_id); $matches = LogifutureData::load($logifuture_sport_id);
// Notice::note($matches, 'b');
if ($echo_data) { if ($echo_data) {
Notice::note($matches, 'g'); Notice::note($matches, 'g');
} }
@@ -54,38 +56,27 @@ class Logifuture
foreach ($matches as $match) { foreach ($matches as $match) {
// Notice::note($match, 'r');
if (strpos($match['sportCategory'], 'Simulated Reality') === false) { if (strpos($match['sportCategory'], 'Simulated Reality') === false) {
$event = MapEvent::filter($sport_id, $match); $event = MapEvent::filter($sport_id, $match);
FindFixture::find($event); FindFixture::find($event);
Notice::note($event, 'r');
if (isset($event['id'])) { if (isset($event['id'])) {
Notice::note($event, 'b');
$event_id_collector[] = $event['id']; $event_id_collector[] = $event['id'];
$max_tries = 5; EventBookmaker::updateOrCreate([
$tries = 0;
do {
$retry = false;
try {
$handle = EventBookmaker::updateOrCreate([
'event_id' => $event['id'], 'event_id' => $event['id'],
'sport_id' => $sport_id, 'sport_id' => $sport_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'], 'bookmaker_id' => Nuh::$options['bookmaker_id'],
], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'startime' => $event['starttime']]); ], ['in_feed' => 1, 'bmoid' => $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);
switch ($sport_id) { switch ($sport_id) {
case 1: case 1:
@@ -106,31 +97,12 @@ class Logifuture
break; break;
} }
} }
} }
} }
} }
} }
if ($event_id_collector) { if ($event_id_collector) {
$max_tries = 5; EventBookmaker::whereNotIn('event_id', $event_id_collector)->where('bookmaker_id', Nuh::$options['bookmaker_id'])->update(['in_feed' => 0]);
$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);
$tables = ['odds_2ways', 'odds_2ways_s1', 'odds_3ways', 'odds_totals', 'odds_points', 'odds_ggng', 'odds_dc', 'odds_tq', 'odds_points_q1', 'odds_totals_q1']; $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) { foreach ($tables as $table) {
@@ -101,7 +101,9 @@ class Icehockey
$res->a3w = number_format($_3way['a3w'], 2); $res->a3w = number_format($_3way['a3w'], 2);
$res->flags = 1; $res->flags = 1;
$res->margin = $_3way['margin']; $res->margin = $_3way['margin'];
DB::transaction(function () use ($res) {
$res->save(); $res->save();
}, 5);
} }
} }
@@ -121,7 +123,9 @@ class Icehockey
$res->a2w = number_format($ml['a2w'], 2); $res->a2w = number_format($ml['a2w'], 2);
$res->flags = 1; $res->flags = 1;
$res->margin = $ml['margin']; $res->margin = $ml['margin'];
DB::transaction(function () use ($res) {
$res->save(); $res->save();
}, 5);
} }
} }
@@ -140,7 +144,9 @@ class Icehockey
$res->a2w = number_format($ml['a2w'], 2); $res->a2w = number_format($ml['a2w'], 2);
$res->flags = 1; $res->flags = 1;
$res->margin = $mls1['margin']; $res->margin = $mls1['margin'];
DB::transaction(function () use ($res) {
$res->save(); $res->save();
}, 5);
} }
} }
@@ -8,7 +8,6 @@ use App\Models\OddsDc;
use App\Models\OddsGgng; use App\Models\OddsGgng;
use App\Models\OddsTotal; use App\Models\OddsTotal;
use App\Models\OddsTq; use App\Models\OddsTq;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
class Soccer class Soccer
@@ -94,8 +93,9 @@ class Soccer
$res->a3w = number_format($_3way['a3w'], 2); $res->a3w = number_format($_3way['a3w'], 2);
$res->flags = 1; $res->flags = 1;
$res->margin = $_3way['margin']; $res->margin = $_3way['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -120,8 +120,9 @@ class Soccer
$res->under = number_format($_total['under'], 2); $res->under = number_format($_total['under'], 2);
$res->flags = 1; $res->flags = 1;
$res->margin = $_total['margin']; $res->margin = $_total['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -141,8 +142,9 @@ class Soccer
$res->ng = number_format($_ggng['ng'], 2); $res->ng = number_format($_ggng['ng'], 2);
$res->flags = 1; $res->flags = 1;
$res->margin = $_ggng['margin']; $res->margin = $_ggng['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -163,8 +165,9 @@ class Soccer
$res->dcx2 = number_format($_dc['dcx2'], 2); $res->dcx2 = number_format($_dc['dcx2'], 2);
$res->flags = 1; $res->flags = 1;
$res->margin = $_dc['margin']; $res->margin = $_dc['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -184,8 +187,9 @@ class Soccer
$res->atq = number_format($_tq['atq'], 2); $res->atq = number_format($_tq['atq'], 2);
$res->flags = 1; $res->flags = 1;
$res->margin = $_tq['margin']; $res->margin = $_tq['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -8,8 +8,8 @@ use App\Console\Commands\Grapper\Logifuture\Tools\LogifutureStoreTotals;
use App\Console\Commands\Nuh; use App\Console\Commands\Nuh;
use App\Models\Odds2way; use App\Models\Odds2way;
use App\Models\Odds2wayS1; use App\Models\Odds2wayS1;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use App\Utilities\Notice;
class Tennis class Tennis
{ {
@@ -76,6 +76,8 @@ class Tennis
$ml = array_merge($ml, $base); $ml = array_merge($ml, $base);
// Notice::note($ml, 'g');
$res = Odds2way::where('event_id', $event['id'])->where('bookmaker_id', $event['bookmaker_id'])->first(); $res = Odds2way::where('event_id', $event['id'])->where('bookmaker_id', $event['bookmaker_id'])->first();
if (! $res) { if (! $res) {
@@ -85,8 +87,9 @@ class Tennis
$res->a2w = number_format($ml['a2w'], 2); $res->a2w = number_format($ml['a2w'], 2);
$res->flags = 1; $res->flags = 1;
$res->margin = $ml['margin']; $res->margin = $ml['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -106,8 +109,9 @@ class Tennis
$res->a2w = number_format($ml['a2w'], 2); $res->a2w = number_format($ml['a2w'], 2);
$res->flags = 1; $res->flags = 1;
$res->margin = $mls1['margin']; $res->margin = $mls1['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -3,7 +3,6 @@
namespace App\Console\Commands\Grapper\Logifuture\Tools; namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Models\OddsPoint; use App\Models\OddsPoint;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
class LogifutureStorePoints class LogifutureStorePoints
@@ -40,8 +39,9 @@ class LogifutureStorePoints
$res->difference = $odds['difference']; $res->difference = $odds['difference'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -3,7 +3,6 @@
namespace App\Console\Commands\Grapper\Logifuture\Tools; namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Models\OddsPointQ1; use App\Models\OddsPointQ1;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
class LogifutureStorePointsQ1 class LogifutureStorePointsQ1
@@ -40,8 +39,9 @@ class LogifutureStorePointsQ1
$res->difference = $odds['difference']; $res->difference = $odds['difference'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -3,7 +3,6 @@
namespace App\Console\Commands\Grapper\Logifuture\Tools; namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Models\OddsTotal; use App\Models\OddsTotal;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
class LogifutureStoreTotals class LogifutureStoreTotals
@@ -40,8 +39,9 @@ class LogifutureStoreTotals
$res->difference = $odds['difference']; $res->difference = $odds['difference'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -3,7 +3,6 @@
namespace App\Console\Commands\Grapper\Logifuture\Tools; namespace App\Console\Commands\Grapper\Logifuture\Tools;
use App\Models\OddsTotalQ1; use App\Models\OddsTotalQ1;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
class LogifutureStoreTotalsQ1 class LogifutureStoreTotalsQ1
@@ -40,8 +39,9 @@ class LogifutureStoreTotalsQ1
$res->difference = $odds['difference']; $res->difference = $odds['difference'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -9,7 +9,6 @@ use App\Models\EventBookmaker;
use App\Models\Sport; use App\Models\Sport;
use App\Utilities\Notice; use App\Utilities\Notice;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use PDOException;
class Fixtures class Fixtures
{ {
@@ -101,33 +100,12 @@ class Fixtures
FindFixture::find($event); FindFixture::find($event);
if (isset($event['id'])) { EventBookmaker::updateOrCreate([
$event_id_collector[] = $event['id'];
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$handle = EventBookmaker::updateOrCreate([
'event_id' => $event['id'], 'event_id' => $event['id'],
'sport_id' => $sport_id, 'sport_id' => $sport_id,
'bookmaker_id' => Nuh::$options['bookmaker_id'], 'bookmaker_id' => Nuh::$options['bookmaker_id'],
], ['in_feed' => 1, 'bmoid' => $event['event_id'], 'starttime' => $event['starttime']]); ], ['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; namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\Odds3way; use App\Models\Odds3way;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStore1x2 class MaglooStore1x2
{ {
@@ -27,8 +27,9 @@ class MaglooStore1x2
$res->a3w = $odds['a3w']; $res->a3w = $odds['a3w'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\Magloo\Odds; namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsDc; use App\Models\OddsDc;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStoreDc class MaglooStoreDc
{ {
@@ -28,8 +28,9 @@ class MaglooStoreDc
$res->dcx2 = $odds['dcx2']; $res->dcx2 = $odds['dcx2'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\Magloo\Odds; namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsGgng; use App\Models\OddsGgng;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStoreGgng class MaglooStoreGgng
{ {
@@ -26,8 +26,9 @@ class MaglooStoreGgng
$res->ng = $odds['ng']; $res->ng = $odds['ng'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\Magloo\Odds; namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsPoint; use App\Models\OddsPoint;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStorePoints class MaglooStorePoints
{ {
@@ -37,8 +37,9 @@ class MaglooStorePoints
$res->active_spread = $odds['active_spread']; $res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference']; $res->difference = $odds['difference'];
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\Magloo\Odds; namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsPointQ1; use App\Models\OddsPointQ1;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStorePointsQ1 class MaglooStorePointsQ1
{ {
@@ -37,8 +37,9 @@ class MaglooStorePointsQ1
$res->active_spread = $odds['active_spread']; $res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference']; $res->difference = $odds['difference'];
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\Magloo\Odds; namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsTotal; use App\Models\OddsTotal;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStoreTotals class MaglooStoreTotals
{ {
@@ -37,8 +37,9 @@ class MaglooStoreTotals
$res->active_spread = $odds['active_spread']; $res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference']; $res->difference = $odds['difference'];
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\Magloo\Odds; namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsTotalQ1; use App\Models\OddsTotalQ1;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStoreTotalsQ1 class MaglooStoreTotalsQ1
{ {
@@ -37,8 +37,9 @@ class MaglooStoreTotalsQ1
$res->active_spread = $odds['active_spread']; $res->active_spread = $odds['active_spread'];
$res->difference = $odds['difference']; $res->difference = $odds['difference'];
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -3,8 +3,8 @@
namespace App\Console\Commands\Grapper\Magloo\Odds; namespace App\Console\Commands\Grapper\Magloo\Odds;
use App\Models\OddsTq; use App\Models\OddsTq;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class MaglooStoreTq class MaglooStoreTq
{ {
@@ -26,8 +26,9 @@ class MaglooStoreTq
$res->htq = $odds['htq']; $res->htq = $odds['htq'];
$res->atq = $odds['atq']; $res->atq = $odds['atq'];
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
+15 -7
View File
@@ -27,9 +27,9 @@ use App\Models\EventBookmaker;
use App\Models\Group; use App\Models\Group;
use App\Models\Supervisor; use App\Models\Supervisor;
use App\Models\TxoddsMarket; use App\Models\TxoddsMarket;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Notice; use App\Utilities\Notice;
use Illuminate\Support\Carbon; use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\DB;
class Odds class Odds
{ {
@@ -238,10 +238,10 @@ class Odds
'competition_group_id' => (int) $row->group['cgid'], 'competition_group_id' => (int) $row->group['cgid'],
]; ];
$res = Event::updateOrCreate(['id' => (int) $row['id']], $event); $res = DB::transaction(function () use ($row, $event) {
if ($res) { return Event::updateOrCreate(['id' => (int) $row['id']], $event);
}, 5);
$event_id = $res->id; $event_id = $res->id;
}
$group = [ $group = [
'competition_group_id' => (string) $row->group['cgid'], '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(); $res = EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->first();
if ($res && $res->starttime != $attributeValue) { if ($res && $res->starttime != $attributeValue) {
$res->starttime = $attributeValue; $res->starttime = $attributeValue;
DatabaseFunctions::save_update($res); DB::transaction(function () use ($res) {
$res->save();
}, 5);
} }
break; break;
} }
@@ -342,13 +345,16 @@ class Odds
$res = EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->first(); $res = EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->first();
if ($res && $res->starttime != $attributeValue) { if ($res && $res->starttime != $attributeValue) {
$res->starttime = $attributeValue; $res->starttime = $attributeValue;
DatabaseFunctions::save_update($res); DB::transaction(function () use ($res) {
$res->save();
}, 5);
} }
break; break;
} }
} }
_2Way::grap($odds, $offer); _2Way::grap($odds, $offer);
break; break;
case 3: case 3:
foreach ($offer->odds->attributes() as $attributeName => $attributeValue) { 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(); $res = EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $bookmaker_id)->first();
if ($res && $res->starttime != $attributeValue) { if ($res && $res->starttime != $attributeValue) {
$res->starttime = $attributeValue; $res->starttime = $attributeValue;
DatabaseFunctions::save_update($res); DB::transaction(function () use ($res) {
$res->save();
}, 5);
} }
break; break;
} }
@@ -3,7 +3,6 @@
namespace App\Console\Commands\Grapper\TxOdds\Odds\Tools; namespace App\Console\Commands\Grapper\TxOdds\Odds\Tools;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use PDOException;
class ActiveSpread 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]); 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'])) { if (in_array($table, ['odds_points', 'odds_points_ht', 'odds_points_q1'])) {
$max_tries = 5; DB::table($table)
$tries = 0;
do {
$retry = false;
try {
$query = DB::table($table)
->where('event_id', $event_id) ->where('event_id', $event_id)
->where('bookmaker_id', $bookmaker_id) ->where('bookmaker_id', $bookmaker_id)
->where('handicap', (float) $value['active_spread']) ->where('handicap', (float) $value['active_spread'])
->update(['active_spread' => 1]); ->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 { } else {
throw $exc; DB::table($table)
}
}
} while ($retry);
} else {
$max_tries = 5;
$tries = 0;
do {
$retry = false;
try {
$query = DB::table($table)
->where('event_id', $event_id) ->where('event_id', $event_id)
->where('bookmaker_id', $bookmaker_id) ->where('bookmaker_id', $bookmaker_id)
->where('total', (float) $value['active_spread']) ->where('total', (float) $value['active_spread'])
->update(['active_spread' => 1]); ->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);
} }
} }
} }
@@ -4,8 +4,8 @@ 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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _2Way class _2Way
{ {
@@ -29,8 +29,9 @@ class _2Way
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $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\Console\Commands\Nuh;
use App\Models\Odds2wayS1; use App\Models\Odds2wayS1;
use App\Utilities\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _2WayS1 class _2WayS1
{ {
@@ -28,8 +28,9 @@ class _2WayS1
$res->a2w = $odds['a2w']; $res->a2w = $odds['a2w'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -4,8 +4,8 @@ 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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _3Way class _3Way
{ {
@@ -31,8 +31,9 @@ class _3Way
$res->a3w = $odds['a3w']; $res->a3w = $odds['a3w'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
} }
@@ -4,8 +4,8 @@ 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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _3WayHt class _3WayHt
{ {
@@ -30,8 +30,9 @@ class _3WayHt
$res->a3w = $odds['a3w']; $res->a3w = $odds['a3w'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -4,8 +4,8 @@ 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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _Dc class _Dc
{ {
@@ -30,8 +30,9 @@ class _Dc
$res->dcx2 = $odds['dcx2']; $res->dcx2 = $odds['dcx2'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -4,8 +4,8 @@ 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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _Dnb class _Dnb
{ {
@@ -28,8 +28,9 @@ class _Dnb
$res->dnb2 = $odds['dnb2']; $res->dnb2 = $odds['dnb2'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -4,8 +4,8 @@ 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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _Ggng class _Ggng
{ {
@@ -28,8 +28,9 @@ class _Ggng
$res->ng = $odds['ng']; $res->ng = $odds['ng'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($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\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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _Points class _Points
{ {
@@ -40,8 +40,9 @@ class _Points
$res->away = $odds['away']; $res->away = $odds['away'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($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\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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _PointsHt class _PointsHt
{ {
@@ -40,8 +40,9 @@ class _PointsHt
$res->away = $odds['away']; $res->away = $odds['away'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($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\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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _PointsQ1 class _PointsQ1
{ {
@@ -40,8 +40,9 @@ class _PointsQ1
$res->away = $odds['away']; $res->away = $odds['away'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($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\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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _Totals class _Totals
{ {
@@ -46,8 +46,9 @@ class _Totals
$res->under = $odds['under']; $res->under = $odds['under'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($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\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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _TotalsHt class _TotalsHt
{ {
@@ -46,8 +46,9 @@ class _TotalsHt
$res->under = $odds['under']; $res->under = $odds['under'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($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\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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _TotalsQ1 class _TotalsQ1
{ {
@@ -46,8 +46,9 @@ class _TotalsQ1
$res->under = $odds['under']; $res->under = $odds['under'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
@@ -4,8 +4,8 @@ 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\DatabaseFunctions;
use App\Utilities\Margin; use App\Utilities\Margin;
use Illuminate\Support\Facades\DB;
class _Tq class _Tq
{ {
@@ -28,8 +28,9 @@ class _Tq
$res->atq = $odds['atq']; $res->atq = $odds['atq'];
$res->flags = 1; $res->flags = 1;
$res->margin = $odds['margin']; $res->margin = $odds['margin'];
DB::transaction(function () use ($res) {
DatabaseFunctions::save_update($res); $res->save();
}, 5);
} }
} }
@@ -3,7 +3,6 @@
namespace App\Console\Commands\Services\Tasks\Alarm; namespace App\Console\Commands\Services\Tasks\Alarm;
use App\Models\EventBookmaker; use App\Models\EventBookmaker;
use PDOException;
class AlarmStore class AlarmStore
{ {
@@ -43,23 +42,6 @@ class AlarmStore
} }
} }
$max_tries = 5; EventBookmaker::where('event_id', $event_id)->where('bookmaker_id', $client_bookmaker_id)->update($update_array);
$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);
} }
} }
+2 -3
View File
@@ -2,8 +2,6 @@
namespace App\Utilities; namespace App\Utilities;
use PDOException;
class DatabaseFunctions class DatabaseFunctions
{ {
public static function save_update($query) public static function save_update($query)
@@ -12,12 +10,13 @@ class DatabaseFunctions
$tries = 0; $tries = 0;
do { do {
$retry = false; $retry = false;
$tries++;
try { try {
$query->save(); $query->save();
return $query; return $query;
} catch (PDOException $exc) { } catch (\PDOException $exc) {
if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) { if ($tries < $max_tries && $exc->errorInfo[0] == 40001 && $exc->errorInfo[1] == 1213) {
$retry = true; $retry = true;
sleep(1); sleep(1);