mapper MaglooKeniaAll wip

This commit is contained in:
salam committed 2026-02-27 15:21:41 +01:00
1 parent a77bc4237b
commit 2f24abbc90
3 files changed
+59 -8

No files matched your search

@@ -0,0 +1,16 @@
<?php
namespace App\Console\Commands\DbMapper\Helper;
use App\Models\CompetitionGroupProvider;
class FindCompetitionGroupById
{
public static function run(&$mapper)
{
if (isset($mapper['group_id'])) {
$mapper['txodds_group_id'] = CompetitionGroupProvider::where('provider_id', $mapper['provider_id'])
->where('provider_group_id', $mapper['group_id'])->value('competition_group_id');
}
}
}
@@ -0,0 +1,21 @@
<?php
namespace App\Console\Commands\DbMapper\Helper;
use App\Models\ElementProvider;
class FindElementById
{
public static function run(&$mapper)
{
if (isset($mapper['home_id']) && $mapper['home_id'] > 0) {
$mapper['txodds_home_id'] = ElementProvider::where('provider_id', $mapper['provider_id'])
->where('provider_element_id', $mapper['home_id'])->value('element_id');
}
if (isset($mapper['away_id']) && $mapper['away_id'] > 0) {
$mapper['txodds_away_id'] = ElementProvider::where('provider_id', $mapper['provider_id'])
->where('provider_element_id', $mapper['away_id'])->value('element_id');
}
}
}
@@ -2,14 +2,13 @@
namespace App\Console\Commands\DbMapper;
use App\Console\Commands\DbMapper\Helper\FindCompetitionGroup;
use App\Console\Commands\DbMapper\Helper\FindElement;
use App\Console\Commands\DbMapper\Helper\FindCompetitionGroupById;
use App\Console\Commands\DbMapper\Helper\FindElementById;
use App\Console\Commands\DbMapper\Store\StoreElement;
use App\Console\Commands\DbMapper\Store\StoreGroup;
use App\Console\Commands\Nuh;
use App\Models\Event;
use App\Models\Mapper;
use App\Models\Sport;
use App\Utilities\Notice;
use Carbon\Carbon;
@@ -28,7 +27,9 @@ class MaglooKeniaAll
Notice::note(Nuh::$options['name'], 'g');
}
$sports = Sport::map('magl');
$sports = [1, 3];
$found = [];
foreach ($sports as $sport_id) {
@@ -36,12 +37,12 @@ class MaglooKeniaAll
foreach ($mappers as $mapper) {
FindElement::run($mapper);
FindElementById::run($mapper);
FindCompetitionGroup::run($mapper);
FindCompetitionGroupById::run($mapper);
if ($debug) {
Notice::note($mapper, 'b');
Notice::note($mapper, 'p');
}
if ($mapper['txodds_home_id'] && $mapper['txodds_away_id'] && $mapper['txodds_group_id']) {
@@ -53,10 +54,19 @@ class MaglooKeniaAll
->where('starttime', '<', $to)
->where('home_id', $mapper['txodds_home_id'])
->where('away_id', $mapper['txodds_away_id'])
->where('competition_group_id', $mapper['txodds_group_id'])
->where('group_id', $mapper['txodds_group_id'])
->first();
if ($event) {
dd($event);
if (! isset($found[$sport_id])) {
$found[$sport_id] = 1;
} else {
$found[$sport_id]++;
}
StoreElement::store($mapper);
StoreGroup::store($mapper);
@@ -84,5 +94,9 @@ class MaglooKeniaAll
}
}
}
if ($debug) {
Notice::note($found, 'g');
}
}
}