mapper wip
This commit is contained in:
1 parent
7b2894682f
commit
93febce6fb
18 files changed
+45151
-63
No files matched your search
@@ -4,6 +4,7 @@ namespace App\Console\Commands\Services;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Console\Commands\Services\Tasks\CallTxoddsMarkets;
|
||||
use App\Console\Commands\Services\Tasks\DBMapper;
|
||||
|
||||
class Services
|
||||
{
|
||||
@@ -13,8 +14,8 @@ class Services
|
||||
case 'Txodds Markets':
|
||||
CallTxoddsMarkets::call();
|
||||
break;
|
||||
case 'Mapper':
|
||||
Mapper::run();
|
||||
case 'DB Mapper':
|
||||
DBMapper::run();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Services\Tasks;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Console\Commands\Services\Tasks\Helper\FindCountry;
|
||||
use App\Console\Commands\Services\Tasks\Helper\FindElement;
|
||||
use App\Console\Commands\Services\Tasks\Helper\FindGroup;
|
||||
use App\Models\Event;
|
||||
use App\Models\Mapper;
|
||||
use App\Utilities\Notice;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class DBMapper
|
||||
{
|
||||
public static function run()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('MAPPER SOCCER', 'g');
|
||||
}
|
||||
|
||||
$events = Mapper::get()->toArray();
|
||||
|
||||
$i = 0;
|
||||
foreach ($events as $event) {
|
||||
|
||||
Notice::note($i);
|
||||
|
||||
FindElement::run($event);
|
||||
|
||||
FindGroup::run($event);
|
||||
|
||||
FindCountry::run($event);
|
||||
|
||||
// print_r($event);
|
||||
|
||||
if ($event['txodds_home_id'] && $event['txodds_away_id'] && $event['txodds_group_id']) {
|
||||
$from = Carbon::createFromDate($event['starttime'])->subDay();
|
||||
|
||||
$to = Carbon::createFromDate($event['starttime'])->addDay();
|
||||
|
||||
// DB::enableQueryLog();
|
||||
|
||||
$query = Event::where('starttime', '>', $from->toDateTimeString())
|
||||
->where('starttime', '<', $to->toDateTimeString())
|
||||
->whereIn('home_id', $event['txodds_home_id'])
|
||||
->whereIn('home_id', $event['txodds_away_id'])
|
||||
->whereIn('competition_group_id', $event['txodds_group_id'])
|
||||
->get();
|
||||
|
||||
// Notice::db(DB::getQueryLog());
|
||||
|
||||
Notice::db($query);
|
||||
}
|
||||
|
||||
$i++;
|
||||
if ($i > 100) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands\Services\Tasks\Helper;
|
||||
|
||||
class ExplodeElement
|
||||
class ExplodeString
|
||||
{
|
||||
public static function grap($str)
|
||||
{
|
||||
@@ -22,7 +22,7 @@ class ExplodeElement
|
||||
|
||||
$_return = [];
|
||||
foreach ($elements as $value) {
|
||||
if (\strlen($value) > 2) {
|
||||
if (\strlen($value) > 3) {
|
||||
$_return[] = $value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Services\Tasks\Helper;
|
||||
|
||||
use App\Models\CountriesItalian;
|
||||
use App\Models\Country;
|
||||
|
||||
class FindCountry
|
||||
{
|
||||
public static function run(&$event)
|
||||
{
|
||||
if ($event['provider_id'] == 10) {
|
||||
// GOLDBET
|
||||
$country = CountriesItalian::where('it', $event['country'])->value('en');
|
||||
|
||||
$event['txodds_country_id'] = Country::where('name', $country)->value('id');
|
||||
} else {
|
||||
|
||||
$country = self::fix_country($event['country']);
|
||||
|
||||
$event['txodds_country_id'] = Country::where('name', $country)->value('id');
|
||||
}
|
||||
}
|
||||
|
||||
public static function fix_country($country)
|
||||
{
|
||||
switch ($country) {
|
||||
case 'Internazionale':
|
||||
case 'International Club':
|
||||
case 'Internazionali Di Club':
|
||||
case 'FIBA Intercontinental Cup':
|
||||
return 'International';
|
||||
case 'Euro Cup':
|
||||
case 'Euro Cup Women':
|
||||
case 'Euroleague':
|
||||
case 'Euroleague Women':
|
||||
return 'Europe';
|
||||
case 'WNBA':
|
||||
return 'USA';
|
||||
default:
|
||||
return $country;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Services\Tasks\Helper;
|
||||
|
||||
use App\Models\Element;
|
||||
use App\Models\ElementProvider;
|
||||
|
||||
class FindElement
|
||||
{
|
||||
public static function run(&$event)
|
||||
{
|
||||
if (isset($event['home_id'])) {
|
||||
$event['txodds_home_id'][] = ElementProvider::where('provider_id', $event['provider_id'])
|
||||
->where('provider_element_id', $event['home_id'])->value('element_id');
|
||||
}
|
||||
if (! $event['txodds_home_id']) {
|
||||
$arr = ExplodeString::grap($event['home']);
|
||||
|
||||
$event['txodds_home_id'] = Element::where('sport_id', $event['sport_id'])
|
||||
->where(function ($query) use ($arr) {
|
||||
foreach ($arr as $str) {
|
||||
$query->orwhere('name', 'like', '%'.$str.'%');
|
||||
}
|
||||
})->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
if (isset($event['away_id'])) {
|
||||
$event['txodds_away_id'][] = ElementProvider::where('provider_id', $event['provider_id'])
|
||||
->where('provider_element_id', $event['away_id'])->value('element_id');
|
||||
}
|
||||
if (! $event['txodds_away_id']) {
|
||||
$arr = ExplodeString::grap($event['away']);
|
||||
|
||||
$event['txodds_away_id'] = Element::where('sport_id', $event['sport_id'])
|
||||
->where(function ($query) use ($arr) {
|
||||
foreach ($arr as $str) {
|
||||
$query->orwhere('name', 'like', '%'.$str.'%');
|
||||
}
|
||||
})->pluck('id')->toArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Services\Tasks\Helper;
|
||||
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\CompetitionGroupProvider;
|
||||
|
||||
class FindGroup
|
||||
{
|
||||
public static function run(&$event)
|
||||
{
|
||||
|
||||
if (isset($event['group_id'])) {
|
||||
$event['txodds_group_id'][] = CompetitionGroupProvider::where('provider_id', $event['provider_id'])
|
||||
->where('provider_group_id', $event['group_id'])->value('competition_group_id');
|
||||
}
|
||||
if (! $event['txodds_group_id']) {
|
||||
$arr = ExplodeString::grap($event['group']);
|
||||
|
||||
$event['txodds_group_id'] = CompetitionGroup::where('sport_id', $event['sport_id'])
|
||||
->where(function ($query) use ($arr) {
|
||||
foreach ($arr as $str) {
|
||||
$query->orwhere('name', 'like', '%'.$str.'%');
|
||||
}
|
||||
})->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Services\Tasks;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Utilities\Notice;
|
||||
|
||||
class Mapper
|
||||
{
|
||||
public static function run()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
switch (Nuh::$options['sport_id']) {
|
||||
case 1:
|
||||
$bookmakers = [10, 14, 16, 35, 36, 46, 128];
|
||||
break;
|
||||
case 2:
|
||||
$bookmakers = [10, 16, 35, 36, 46, 128];
|
||||
break;
|
||||
case 3:
|
||||
$bookmakers = [128, 10, 16, 35, 36, 46];
|
||||
break;
|
||||
case 5:
|
||||
$bookmakers = [128, 10, 16, 35, 36, 46];
|
||||
break;
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('MAPPER SOCCER', 'g');
|
||||
}
|
||||
|
||||
$results = [];
|
||||
|
||||
foreach ($bookmakers as $$bookmaker_id) {
|
||||
// code...
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user