grapper wip
This commit is contained in:
1 parent
562c65f331
commit
4184acdb8a
60 files changed
+28840
-398
No files matched your search
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\TxOdds\Odds;
|
||||
|
||||
use App\Models\OddsDnb;
|
||||
use App\Utilities\Margin;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class _Dnb
|
||||
{
|
||||
@@ -14,14 +14,20 @@ class _Dnb
|
||||
$odds['dnb2'] = (float) $value->o3;
|
||||
}
|
||||
$odds['margin'] = (float) Margin::calculate([$odds['dnb1'], $odds['dnb2']], 1);
|
||||
$odds['updated_at'] = now();
|
||||
DB::table('odds_dnb')->upsert(
|
||||
$odds,
|
||||
|
||||
['event_id', 'bookmaker_id'],
|
||||
$res = OddsDnb::where('event_id', $odds['event_id'])->where('bookmaker_id', $odds['bookmaker_id'])->first();
|
||||
|
||||
['dnb1', 'dnb2', 'margin', 'flags', 'updated_at']
|
||||
|
||||
);
|
||||
if (! $res) {
|
||||
OddsDnb::create($odds);
|
||||
} else {
|
||||
$res->dnb1 = $odds['dnb1'];
|
||||
$res->dnb2 = $odds['dnb2'];
|
||||
if ($res->isDirty()) {
|
||||
$res->oddchange_at = now();
|
||||
}
|
||||
$res->checked_at = $odds['checked_at'];
|
||||
$res->margin = $odds['margin'];
|
||||
$res->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user