fix mapper
This commit is contained in:
1 parent
b4b3f1e1ea
commit
336af556a1
9 files changed
+893
-1432
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\Events;
|
||||
use App\Console\Commands\Grapper\Sofascore\Tournament;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreCategorie;
|
||||
@@ -31,13 +32,16 @@ class Sofascore
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
Notice::note(Nuh::$options['sport'].' '.Nuh::$options['name'], 'b');
|
||||
Notice::note(Nuh::$options['sport'] . ' ' . Nuh::$options['name'], 'b');
|
||||
}
|
||||
|
||||
switch (Nuh::$options['name']) {
|
||||
case 'TOURNAMENTS':
|
||||
Tournament::load();
|
||||
break;
|
||||
case 'EVENTS':
|
||||
Events::load();
|
||||
break;
|
||||
|
||||
default:
|
||||
// code...
|
||||
|
||||
@@ -20,13 +20,18 @@ class Events
|
||||
|
||||
public static $sport = [1];
|
||||
|
||||
public static function switch()
|
||||
public static function load()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$sportmap = Sport::whereIn('id', self::$sport)->select('id', 'sofascore', 'ss_slug')->get();
|
||||
$sport_id = Nuh::$options['sport_id'];
|
||||
|
||||
$time_zone_offset = 0;
|
||||
$sport = Sport::where('id', $sport_id)->first();
|
||||
|
||||
$dates = Carbon::now();
|
||||
|
||||
// to grap event id
|
||||
// https://www.sofascore.com/api/v1/unique-tournament/2480/scheduled-events/2022-05-19
|
||||
|
||||
$years_back = 7;
|
||||
|
||||
@@ -46,7 +51,7 @@ class Events
|
||||
$page = 1;
|
||||
|
||||
while ($page) {
|
||||
$url = Nuh::$options['base_url']."api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page";
|
||||
$url = Nuh::$options['base_url'] . "api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page";
|
||||
|
||||
$data = Curl::load($url);
|
||||
|
||||
|
||||
@@ -16,12 +16,6 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class Tournament
|
||||
{
|
||||
public static $auth_header = [];
|
||||
|
||||
public static $base_url = '';
|
||||
|
||||
public static $sport = [1];
|
||||
|
||||
public static function load()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
@@ -44,13 +38,13 @@ class Tournament
|
||||
if (! SofaScoreDay::where('day', $day)->where($sport->ss_slug, 1)->first()) {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('Grapping Sport: '.Nuh::$options['sport'].' Day: '.$day, 'g');
|
||||
Notice::note('Grapping Sport: ' . Nuh::$options['sport'] . ' Day: ' . $day, 'g');
|
||||
}
|
||||
|
||||
$page = 1;
|
||||
|
||||
while ($page) {
|
||||
$url = Nuh::$options['base_url']."api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page";
|
||||
$url = Nuh::$options['base_url'] . "api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
if ($debug) {
|
||||
@@ -164,7 +158,6 @@ class Tournament
|
||||
Notice::note("tournaments: $tournaments_counter", 'p');
|
||||
|
||||
SofaScoreDay::updateOrCreate(['day' => $day], [$sport->ss_slug => 1]);
|
||||
|
||||
}
|
||||
|
||||
if (Nuh::$options['test']) {
|
||||
@@ -172,7 +165,7 @@ class Tournament
|
||||
}
|
||||
} else {
|
||||
if ($debug) {
|
||||
Notice::note('Having Sport: '.Nuh::$options['sport'].' Day: '.$day, 'b');
|
||||
Notice::note('Having Sport: ' . Nuh::$options['sport'] . ' Day: ' . $day, 'b');
|
||||
}
|
||||
}
|
||||
$dates->subDay();
|
||||
|
||||
Reference in new issue
Block a user