This commit is contained in:
salam committed 2026-06-07 07:42:20 +02:00
1 parent 292acb879e
commit 2b85bf890c
4 files changed
+24 -14

No files matched your search

+2 -2
View File
@@ -20,12 +20,12 @@ class Sofascore
public static function switch()
{
$debug = Nuh::$options['d'] ?? 0;
$truncat = Nuh::$options['t'] ?? 0;
if ($truncat) {
if (Nuh::$options['truncate']) {
SofaScoreDayTournament::truncate();
SofaScoreTournament::truncate();
SofaScoreCategorie::truncate();
Notice::note('Table SofaScoreDayTournament, SofaScoreTournament, SofaScoreCategorie truncated', 'b', 1);
}
if ($debug) {
@@ -25,37 +25,37 @@ class Tournament
{
$debug = Nuh::$options['d'] ?? 0;
$YEAR_GO_BACK = date('Y') - 5;
$sport_id = Nuh::$options['sport_id'];
$slug = Sport::where('id', $sport_id)->value('ss_slug');
$sport = Sport::where('id', $sport_id)->first();
$dates = Carbon::now();
while ($dates >= Carbon::now()->subYears($YEAR_GO_BACK)) {
while ($dates >= Carbon::now()->subYears($sport->ss_grap_years)) {
$tournaments_counter = 0;
$day = $dates->format('Y-m-d');
Notice::note('sport: '.Nuh::$options['sport'].' day: '.$day, 'p');
/**
* grap only one time/sport check
*/
if (! SofaScoreDay::where('day', $day)->where($slug, 1)->first()) {
if (! SofaScoreDay::where('day', $day)->where($sport->ss_slug, 1)->first()) {
SofaScoreDay::updateOrCreate(['day' => $day], [$slug => 1]);
if ($debug) {
Notice::note('Grapping Sport: '.Nuh::$options['sport'].' Day: '.$day, 'g');
}
SofaScoreDay::updateOrCreate(['day' => $day], [$sport->ss_slug => 1]);
$page = 1;
while ($page) {
$url = Nuh::$options['base_url']."api/v1/sport/$slug/scheduled-tournaments/$day/page/$page";
$url = Nuh::$options['base_url']."api/v1/sport/$sport->ss_slug/scheduled-tournaments/$day/page/$page";
$rand = rand(1000000, 2000000);
if ($debug) {
Notice::note("Sleep $rand msec", 'g');
Notice::note("Sleep $rand msec", 'y');
}
usleep($rand);
@@ -152,6 +152,14 @@ class Tournament
Notice::note("tournaments: $tournaments_counter", 'p');
}
if (Nuh::$options['test']) {
Notice::note('Test exit after one day', 'b', 1);
}
} else {
if ($debug) {
Notice::note('Having Sport: '.Nuh::$options['sport'].' Day: '.$day, 'b');
}
}
$dates->subDay();
}
+3 -1
View File
@@ -23,7 +23,7 @@ class Nuh extends Command
public static $id = 0;
protected $signature = 'nuh {process=help} {--id=0} {--fn=} {--gid=} {--p} {--d} {--x} {--t} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e}';
protected $signature = 'nuh {process=help} {--truncate} {--test} {--id=0} {--fn=} {--gid=} {--p} {--d} {--x} {--t} {--w} {--a} {--r} {--s} {--g} {--t} {--q} {--f} {--b} {--e}';
public function handle()
{
@@ -40,6 +40,8 @@ class Nuh extends Command
$txt .= '--id=matchid (optional) calling spezific id'.PHP_EOL;
$txt .= '--fn=name (optional) [bkms, markets]'.PHP_EOL;
$txt .= '--gid=groupid (optional) [bkms, groupid]'.PHP_EOL;
$txt .= '--truncate (optional)'.PHP_EOL;
$txt .= '--test (optional)'.PHP_EOL;
$txt .= '----------------------------------------------'.PHP_EOL.PHP_EOL;
$txt .= 'Options'.PHP_EOL;
$txt .= '----------------------------------------------'.PHP_EOL;
@@ -13,7 +13,7 @@ class ListSofaScoreTournaments extends ListRecords
protected function getHeaderActions(): array
{
return [
CreateAction::make(),
// CreateAction::make(),
];
}
}