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
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user