From 13eadd045b0a744b6265002a672c75abf9f95143 Mon Sep 17 00:00:00 2001 From: salam Date: Mon, 16 Feb 2026 11:00:03 +0100 Subject: [PATCH] wip db --- .../Commands/Grapper/TxOdds/Odds/_Points.php | 35 ++++++++++--------- .../Grapper/TxOdds/Odds/_PointsHt.php | 34 +++++++++--------- .../Grapper/TxOdds/Odds/_PointsQ1.php | 34 +++++++++--------- .../Commands/Grapper/TxOdds/Odds/_Totals.php | 34 +++++++++--------- .../Grapper/TxOdds/Odds/_TotalsHt.php | 35 ++++++++++--------- .../Grapper/TxOdds/Odds/_TotalsQ1.php | 34 +++++++++--------- 6 files changed, 110 insertions(+), 96 deletions(-) diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_Points.php b/app/Console/Commands/Grapper/TxOdds/Odds/_Points.php index f08905bd..90d3c22b 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_Points.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_Points.php @@ -24,26 +24,29 @@ class _Points return; } - $odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']); + if ($odds['home'] >= 1 && $odds['away'] >= 1) { - $odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1); + $odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']); - $res = OddsPoint::where('event_id', $odds['event_id']) - ->where('bookmaker_id', $odds['bookmaker_id']) - ->where('handicap', $odds['handicap']) - ->first(); + $odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1); - if (! $res) { - OddsPoint::create($odds); - } elseif (! $block_update) { - $res->home = $odds['home']; - $res->away = $odds['away']; - $res->flags = 1; - $res->margin = $odds['margin']; - DB::transaction(function () use ($res) { - $res->save(); - }, 5); + $res = OddsPoint::where('event_id', $odds['event_id']) + ->where('bookmaker_id', $odds['bookmaker_id']) + ->where('handicap', $odds['handicap']) + ->first(); + if (! $res) { + OddsPoint::create($odds); + } elseif (! $block_update) { + $res->home = $odds['home']; + $res->away = $odds['away']; + $res->flags = 1; + $res->margin = $odds['margin']; + DB::transaction(function () use ($res) { + $res->save(); + }, 5); + + } } ActiveSpread::collect($odds, 'odds_points'); diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_PointsHt.php b/app/Console/Commands/Grapper/TxOdds/Odds/_PointsHt.php index da8a5e10..d430bafc 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_PointsHt.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_PointsHt.php @@ -24,26 +24,28 @@ class _PointsHt return; } - $odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']); + if ($odds['home'] >= 1 && $odds['away'] >= 1) { + $odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']); - $odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1); + $odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1); - $res = OddsPointHt::where('event_id', $odds['event_id']) - ->where('bookmaker_id', $odds['bookmaker_id']) - ->where('handicap', $odds['handicap']) - ->first(); + $res = OddsPointHt::where('event_id', $odds['event_id']) + ->where('bookmaker_id', $odds['bookmaker_id']) + ->where('handicap', $odds['handicap']) + ->first(); - if (! $res) { - OddsPointHt::create($odds); - } elseif (! $block_update) { - $res->home = $odds['home']; - $res->away = $odds['away']; - $res->flags = 1; - $res->margin = $odds['margin']; - DB::transaction(function () use ($res) { - $res->save(); - }, 5); + if (! $res) { + OddsPointHt::create($odds); + } elseif (! $block_update) { + $res->home = $odds['home']; + $res->away = $odds['away']; + $res->flags = 1; + $res->margin = $odds['margin']; + DB::transaction(function () use ($res) { + $res->save(); + }, 5); + } } ActiveSpread::collect($odds, 'odds_points_ht'); diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_PointsQ1.php b/app/Console/Commands/Grapper/TxOdds/Odds/_PointsQ1.php index e59ddb4b..a7f59a2b 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_PointsQ1.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_PointsQ1.php @@ -24,26 +24,28 @@ class _PointsQ1 return; } - $odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']); + if ($odds['home'] >= 1 && $odds['away'] >= 1) { + $odds['difference'] = abs(1 / $odds['home'] - 1 / $odds['away']); - $odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1); + $odds['margin'] = (float) Margin::calculate([$odds['home'], $odds['away']], 1); - $res = OddsPointQ1::where('event_id', $odds['event_id']) - ->where('bookmaker_id', $odds['bookmaker_id']) - ->where('handicap', $odds['handicap']) - ->first(); + $res = OddsPointQ1::where('event_id', $odds['event_id']) + ->where('bookmaker_id', $odds['bookmaker_id']) + ->where('handicap', $odds['handicap']) + ->first(); - if (! $res) { - OddsPointQ1::create($odds); - } elseif (! $block_update) { - $res->home = $odds['home']; - $res->away = $odds['away']; - $res->flags = 1; - $res->margin = $odds['margin']; - DB::transaction(function () use ($res) { - $res->save(); - }, 5); + if (! $res) { + OddsPointQ1::create($odds); + } elseif (! $block_update) { + $res->home = $odds['home']; + $res->away = $odds['away']; + $res->flags = 1; + $res->margin = $odds['margin']; + DB::transaction(function () use ($res) { + $res->save(); + }, 5); + } } ActiveSpread::collect($odds, 'odds_points_q1'); diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_Totals.php b/app/Console/Commands/Grapper/TxOdds/Odds/_Totals.php index a8e9cd05..f872d5f6 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_Totals.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_Totals.php @@ -30,26 +30,28 @@ class _Totals } } - $odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']); + if ($odds['over'] >= 1 && $odds['under'] >= 1) { - $odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1); + $odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']); - $res = OddsTotal::where('event_id', $odds['event_id']) - ->where('bookmaker_id', $odds['bookmaker_id']) - ->where('total', $odds['total']) - ->first(); + $odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1); - if (! $res) { - OddsTotal::create($odds); - } elseif (! $block_update) { - $res->over = $odds['over']; - $res->under = $odds['under']; - $res->flags = 1; - $res->margin = $odds['margin']; - DB::transaction(function () use ($res) { - $res->save(); - }, 5); + $res = OddsTotal::where('event_id', $odds['event_id']) + ->where('bookmaker_id', $odds['bookmaker_id']) + ->where('total', $odds['total']) + ->first(); + if (! $res) { + OddsTotal::create($odds); + } elseif (! $block_update) { + $res->over = $odds['over']; + $res->under = $odds['under']; + $res->flags = 1; + $res->margin = $odds['margin']; + DB::transaction(function () use ($res) { + $res->save(); + }, 5); + } } ActiveSpread::collect($odds, 'odds_totals'); diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsHt.php b/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsHt.php index 7743989b..1cb1ffc4 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsHt.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsHt.php @@ -30,26 +30,29 @@ class _TotalsHt } } - $odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']); + if ($odds['over'] >= 1 && $odds['under'] >= 1) { - $odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1); + $odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']); - $res = OddsTotalHt::where('event_id', $odds['event_id']) - ->where('bookmaker_id', $odds['bookmaker_id']) - ->where('total', $odds['total']) - ->first(); + $odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1); - if (! $res) { - OddsTotalHt::create($odds); - } elseif (! $block_update) { - $res->over = $odds['over']; - $res->under = $odds['under']; - $res->flags = 1; - $res->margin = $odds['margin']; - DB::transaction(function () use ($res) { - $res->save(); - }, 5); + $res = OddsTotalHt::where('event_id', $odds['event_id']) + ->where('bookmaker_id', $odds['bookmaker_id']) + ->where('total', $odds['total']) + ->first(); + if (! $res) { + OddsTotalHt::create($odds); + } elseif (! $block_update) { + $res->over = $odds['over']; + $res->under = $odds['under']; + $res->flags = 1; + $res->margin = $odds['margin']; + DB::transaction(function () use ($res) { + $res->save(); + }, 5); + + } } ActiveSpread::collect($odds, 'odds_totals_ht'); diff --git a/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsQ1.php b/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsQ1.php index 1f7236a4..a05b833b 100644 --- a/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsQ1.php +++ b/app/Console/Commands/Grapper/TxOdds/Odds/_TotalsQ1.php @@ -30,26 +30,28 @@ class _TotalsQ1 } } - $odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']); + if ($odds['over'] >= 1 && $odds['under'] >= 1) { - $odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1); + $odds['difference'] = abs(1 / $odds['over'] - 1 / $odds['under']); - $res = OddsTotalQ1::where('event_id', $odds['event_id']) - ->where('bookmaker_id', $odds['bookmaker_id']) - ->where('total', $odds['total']) - ->first(); + $odds['margin'] = (float) Margin::calculate([$odds['over'], $odds['under']], 1); - if (! $res) { - OddsTotalQ1::create($odds); - } elseif (! $block_update) { - $res->over = $odds['over']; - $res->under = $odds['under']; - $res->flags = 1; - $res->margin = $odds['margin']; - DB::transaction(function () use ($res) { - $res->save(); - }, 5); + $res = OddsTotalQ1::where('event_id', $odds['event_id']) + ->where('bookmaker_id', $odds['bookmaker_id']) + ->where('total', $odds['total']) + ->first(); + if (! $res) { + OddsTotalQ1::create($odds); + } elseif (! $block_update) { + $res->over = $odds['over']; + $res->under = $odds['under']; + $res->flags = 1; + $res->margin = $odds['margin']; + DB::transaction(function () use ($res) { + $res->save(); + }, 5); + } } ActiveSpread::collect($odds, 'odds_totals_q1');