changes to grapper wip
This commit is contained in:
1 parent
361e5ed3ed
commit
9214da8a15
9 files changed
+311
-67
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace App\Console\Commands\Grapper;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\Events;
|
||||
use App\Console\Commands\Grapper\Sofascore\EventsDatabase;
|
||||
use App\Console\Commands\Grapper\Sofascore\Special;
|
||||
use App\Console\Commands\Grapper\Sofascore\Tournament;
|
||||
use App\Console\Commands\Nuh;
|
||||
@@ -17,8 +18,11 @@ use Illuminate\Support\Carbon;
|
||||
class Sofascore
|
||||
{
|
||||
public static $auth_header = [];
|
||||
|
||||
public static $base_url = '';
|
||||
|
||||
public static $_days = [];
|
||||
|
||||
public static $sport = [1];
|
||||
|
||||
public static function switch()
|
||||
@@ -36,8 +40,9 @@ class Sofascore
|
||||
if (Nuh::$options['t']) {
|
||||
self::$_days[] = Carbon::now()->format('Y-m-d');
|
||||
} elseif (Nuh::$options['day']) {
|
||||
if (self::validateDate(Nuh::$options['day'])) {
|
||||
self::$_days[] = Nuh::$options['day'];
|
||||
$day = self::validateDate(Nuh::$options['day']);
|
||||
if ($day) {
|
||||
self::$_days[] = $day;
|
||||
} else {
|
||||
Notice::note('date not valid '.Nuh::$options['day'], 'r', 1);
|
||||
}
|
||||
@@ -61,6 +66,9 @@ class Sofascore
|
||||
case 'EVENTS':
|
||||
Events::load();
|
||||
break;
|
||||
case 'EVENTSDB':
|
||||
EventsDatabase::load();
|
||||
break;
|
||||
case 'SPECIAL':
|
||||
Special::load();
|
||||
break;
|
||||
@@ -73,7 +81,13 @@ class Sofascore
|
||||
|
||||
public static function validateDate($date, $format = 'Y-m-d')
|
||||
{
|
||||
if (is_numeric($date)) {
|
||||
$date = date('Y').'-'.date('m').'-'.$date;
|
||||
}
|
||||
$d = DateTime::createFromFormat($format, $date);
|
||||
return $d && $d->format($format) == $date;
|
||||
|
||||
if ($d && $d->format($format) == $date) {
|
||||
return $d->format($format);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1 @@
|
||||
/grapped
|
||||
/worldcup-teams
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreDayTournament;
|
||||
use App\Utilities\Notice;
|
||||
@@ -18,8 +17,8 @@ class Events
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
$print = Nuh::$options['p'] ?? 0;
|
||||
$sport_id = Nuh::$options['sport_id'];
|
||||
$dback = Nuh::$options['days'] ?? 1;
|
||||
|
||||
$dback = Nuh::$options['days'] ?? 1;
|
||||
$singleday = Nuh::$options['day'] ?? 0;
|
||||
if ($singleday) {
|
||||
$dback = 1;
|
||||
@@ -52,30 +51,14 @@ class Events
|
||||
* finland veikkaus => 41
|
||||
*/
|
||||
$tornaments = explode(',', Nuh::$options['groups']) ?? 0;
|
||||
|
||||
|
||||
// for ($i = 1; $i <= $dback; $i++) {
|
||||
// // remove one day to start yesterday
|
||||
// $day = Carbon::now()->subDays($i)->format('Y-m-d');
|
||||
// if ($debug) {
|
||||
// Notice::note($day, 'p');
|
||||
// }
|
||||
// $ss_days = SofaScoreDayTournament::with('tournament')
|
||||
// ->when($tornaments, function ($query) use ($tornaments) {
|
||||
// return $query->whereIn('tournament_id', $tornaments);
|
||||
// })
|
||||
// ->whereHas('tournament', function ($query) use ($sport_id) {
|
||||
// $query->where('sport_id', $sport_id);
|
||||
// })
|
||||
// ->where('day', $day)->get();
|
||||
// foreach ($ss_days as $ss_day) {
|
||||
// $sofa_score_categorie_id = $ss_day->tournament->sofa_score_categorie_id;
|
||||
// // https://www.sofascore.com/api/v1/unique-tournament/16/scheduled-events/2026-06-19
|
||||
// $url = Nuh::$options['base_url'] . "api/v1/category/$sofa_score_categorie_id/scheduled-events/$day";
|
||||
// Notice::note($url, 'p');
|
||||
// }
|
||||
// }
|
||||
// exit;
|
||||
if (array_sum($tornaments)) {
|
||||
if ($debug) {
|
||||
Notice::note('groups and day(s) used from comandline', 'p');
|
||||
}
|
||||
if (! Nuh::$options['days'] or ! Nuh::$options['day']) {
|
||||
Notice::note('no day(s) option in comandline (--day=1)', 'r', 1);
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $dback; $i++) {
|
||||
|
||||
@@ -104,6 +87,7 @@ class Events
|
||||
foreach ($ss_days as $ss_day) {
|
||||
|
||||
$sofa_score_categorie_id = $ss_day->tournament->sofa_score_categorie_id;
|
||||
|
||||
$tournament_id = $ss_day->tournament_id;
|
||||
|
||||
// $url = Nuh::$options['base_url'] . "api/v1/category/$sofa_score_categorie_id/scheduled-events/$day";
|
||||
@@ -172,7 +156,6 @@ class Events
|
||||
|
||||
File::put($folder.'/lineups.json', json_encode($data));
|
||||
|
||||
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreDay;
|
||||
use App\Models\SofaScoreTournament;
|
||||
use App\Utilities\Notice;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class EventsDatabase
|
||||
{
|
||||
public static $storage_path = '/Console/Commands/Grapper/Sofascore/grapped/';
|
||||
|
||||
public static function load()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
$print = Nuh::$options['p'] ?? 0;
|
||||
$sport_id = Nuh::$options['sport_id'];
|
||||
|
||||
$days = SofaScoreDay::where('sport_id', $sport_id)->where('enabled', 1)->pluck('day')->toArray();
|
||||
$tornaments = SofaScoreTournament::where('sport_id', $sport_id)->where('enabled', 1)->get();
|
||||
|
||||
if (! $days) {
|
||||
Notice::note('No days active in DB', 'r', 1);
|
||||
}
|
||||
if (! $tornaments) {
|
||||
Notice::note('No tornaments active in DB', 'r', 1);
|
||||
}
|
||||
|
||||
if ($print) {
|
||||
dd($days, $tornaments);
|
||||
}
|
||||
|
||||
foreach ($days as $day) {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note($day, 'b');
|
||||
}
|
||||
|
||||
foreach ($tornaments as $tournament) {
|
||||
|
||||
if ($debug) {
|
||||
Notice::note($tournament->name, 'b');
|
||||
}
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/unique-tournament/$tournament->tournament_id/scheduled-events/$day";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
|
||||
if ($debug) {
|
||||
Notice::note("Sleep $rand msec", 'y');
|
||||
}
|
||||
|
||||
usleep($rand);
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
Nuh::$options['s'] = 0;
|
||||
|
||||
Nuh::$options['r'] = 0;
|
||||
|
||||
if (isset($data['events'])) {
|
||||
|
||||
foreach ($data['events'] as $event) {
|
||||
|
||||
Notice::note($event['season']['name'].' '.$day, 'bb');
|
||||
|
||||
$folder = app_path().self::$storage_path.$day.'/'.$event['tournament']['slug'].'/'.$event['slug'];
|
||||
|
||||
File::makeDirectory($folder, 0775, true, true);
|
||||
|
||||
/*********************************
|
||||
* EVENT event
|
||||
*********************************/
|
||||
|
||||
File::put($folder.'/event.json', json_encode($event));
|
||||
|
||||
/*********************************
|
||||
* EVENT statistics
|
||||
*********************************/
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/statistics";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
if ($debug) {
|
||||
Notice::note("Sleep $rand msec", 'y');
|
||||
}
|
||||
usleep($rand);
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
File::put($folder.'/statistics.json', json_encode($data));
|
||||
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/lineups";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
if ($debug) {
|
||||
Notice::note("Sleep $rand msec", 'y');
|
||||
}
|
||||
usleep($rand);
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
File::put($folder.'/lineups.json', json_encode($data));
|
||||
|
||||
/*********************************
|
||||
* EVENT lineups
|
||||
*********************************/
|
||||
|
||||
$event_id = $event['id'];
|
||||
|
||||
$url = Nuh::$options['base_url']."api/v1/event/$event_id/odds/1/all";
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
if ($debug) {
|
||||
Notice::note("Sleep $rand msec", 'y');
|
||||
}
|
||||
usleep($rand);
|
||||
|
||||
$data = CurlSofa::load($url);
|
||||
|
||||
File::put($folder.'/odds.json', json_encode($data));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ ini_set('magic_quotes_runtime', false);
|
||||
|
||||
class Special
|
||||
{
|
||||
|
||||
public static $max_days = 30;
|
||||
|
||||
public static Carbon $days_back;
|
||||
|
||||
public static $storage_path = '/Console/Commands/Grapper/Sofascore/worldcup-teams/';
|
||||
@@ -21,7 +21,7 @@ class Special
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$url = Nuh::$options['base_url'] . "/api/v1/world-cup/meet-the-team";
|
||||
$url = Nuh::$options['base_url'].'/api/v1/world-cup/meet-the-team';
|
||||
|
||||
$rand = rand(500000, 1000000);
|
||||
if ($debug) {
|
||||
@@ -38,7 +38,7 @@ class Special
|
||||
$teams[] = [
|
||||
'id' => $team['team']['id'],
|
||||
'slug' => $team['team']['slug'],
|
||||
'name' => $team['team']['name']
|
||||
'name' => $team['team']['name'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Enums\Size;
|
||||
use Filament\Support\Enums\TextSize;
|
||||
use Filament\Tables\Columns\Layout\Split;
|
||||
use Filament\Tables\Columns\Layout\Stack;
|
||||
@@ -107,7 +106,8 @@ class SupervisorsTable
|
||||
case 12:
|
||||
return [
|
||||
'TOURNAMENTS' => 'TOURNAMENTS',
|
||||
'EVENTS' => 'EVENTS',
|
||||
'EVENTS' => 'EVENTS Comandline',
|
||||
'EVENTSDB' => 'EVENTS Database',
|
||||
'SPECIAL' => 'SPECIAL',
|
||||
];
|
||||
default:
|
||||
|
||||
+49
-18
@@ -5,12 +5,8 @@ namespace App\Filament\Clusters\StaticData\Resources\SofaScoreDays\Tables;
|
||||
use App\Models\SofaScoreDay;
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
@@ -27,15 +23,52 @@ class SofaScoreDaysTable
|
||||
return $table
|
||||
->description('For days checked events active in tournaments will be grapped.')
|
||||
->headerActions([
|
||||
Action::make('reset')->icon('phosphor-power')->action(fn() => SofaScoreDay::query()->update(['football' => 0])),
|
||||
Action::make('generate')->icon('phosphor-calendar')
|
||||
->schema([
|
||||
Select::make('sport_id')
|
||||
->options(Sport::where('is_active', 1)
|
||||
->pluck('name', 'id'))
|
||||
->required(),
|
||||
Select::make('year')
|
||||
->options(self::years())
|
||||
->required(),
|
||||
Select::make('month')
|
||||
->options(self::month())
|
||||
->required(),
|
||||
])
|
||||
->action(function (array $data, $table): void {
|
||||
$sport_id = $data['sport_id'];
|
||||
$date = Carbon::createFromDate($data['year'], $data['month'], 1)->startOfMonth();
|
||||
$daysCount = $date->daysInMonth;
|
||||
|
||||
$allDates = [];
|
||||
for ($i = 1; $i <= $daysCount; $i++) {
|
||||
$allDates[] = $date->copy()->day($i)->format('Y-m-d');
|
||||
}
|
||||
foreach ($allDates as $day) {
|
||||
SofaScoreDay::updateOrCreate(['day' => $day, 'sport_id' => $sport_id]);
|
||||
}
|
||||
}),
|
||||
Action::make('reset')
|
||||
->icon('phosphor-power')
|
||||
->schema([
|
||||
Select::make('sport_id')
|
||||
->options(Sport::where('is_active', 1)
|
||||
->pluck('name', 'id'))
|
||||
->required(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$sport_id = $data['sport_id'];
|
||||
SofaScoreDay::where('sport_id', $sport_id)->update(['enabled' => 0]);
|
||||
}),
|
||||
])
|
||||
->columns([
|
||||
TextColumn::make('day')->sortable(),
|
||||
TextColumn::make('sport.name'),
|
||||
TextColumn::make('day')->sortable(),
|
||||
ToggleColumn::make('enabled'),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('day')
|
||||
Filter::make('filter')
|
||||
->columns(4)->columnSpan(4)
|
||||
->schema([
|
||||
Select::make('sport_id')
|
||||
@@ -66,31 +99,29 @@ class SofaScoreDaysTable
|
||||
if ($data['month'] ?? null) {
|
||||
$indicators[] = Indicator::make('Month: '.$data['month']);
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
// DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
->persistFiltersInSession()
|
||||
->deferFilters(false);
|
||||
}
|
||||
|
||||
public static function years() {
|
||||
public static function years()
|
||||
{
|
||||
$years = range(date('Y'), date('Y') - 10);
|
||||
|
||||
return array_combine($years, $years);
|
||||
}
|
||||
|
||||
public static function month() {
|
||||
public static function month()
|
||||
{
|
||||
$months = [];
|
||||
for ($m = 1; $m <= 12; $m++) {
|
||||
$date = Carbon::create(null, $m, 1);
|
||||
$months[$date->format('m')] = $date->format('F');
|
||||
}
|
||||
|
||||
return $months;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -65,7 +65,7 @@ class SofaScoreTournamentsTable
|
||||
->size(IconSize::Medium)
|
||||
->tooltip(fn ($record) => $record->id)
|
||||
->visibleFrom('lg'),
|
||||
TextColumn::make('tournament_id')->sortable(),
|
||||
TextColumn::make('tournament_id')->sortable()->searchable(),
|
||||
TextColumn::make('sport.name'),
|
||||
TextColumn::make('sofascore_category.name')
|
||||
->icon(fn ($record) => $record->sofascore_category->country->icon),
|
||||
|
||||
Generated
+92
-12
@@ -4457,24 +4457,24 @@
|
||||
},
|
||||
{
|
||||
"name": "mongodb/mongodb",
|
||||
"version": "2.2.0",
|
||||
"version": "2.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mongodb/mongo-php-library.git",
|
||||
"reference": "bbb13f969e37e047fd822527543df55fdc1c9298"
|
||||
"url": "https://github.com/mongodb/mongo-php-library",
|
||||
"reference": "12e56461166d915e3dd8e4969ad0940ed5207d88"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/bbb13f969e37e047fd822527543df55fdc1c9298",
|
||||
"reference": "bbb13f969e37e047fd822527543df55fdc1c9298",
|
||||
"url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/12e56461166d915e3dd8e4969ad0940ed5207d88",
|
||||
"reference": "12e56461166d915e3dd8e4969ad0940ed5207d88",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer-runtime-api": "^2.0",
|
||||
"ext-mongodb": "^2.2",
|
||||
"ext-mongodb": "^2.3",
|
||||
"php": "^8.1",
|
||||
"psr/log": "^1.1.4|^2|^3",
|
||||
"symfony/polyfill-php85": "^1.32"
|
||||
"symfony/polyfill-php85": "^1.33"
|
||||
},
|
||||
"replace": {
|
||||
"mongodb/builder": "*"
|
||||
@@ -4526,11 +4526,7 @@
|
||||
"mongodb",
|
||||
"persistence"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/mongodb/mongo-php-library/issues",
|
||||
"source": "https://github.com/mongodb/mongo-php-library/tree/2.2.0"
|
||||
},
|
||||
"time": "2026-02-11T11:39:56+00:00"
|
||||
"time": "2026-04-28T12:50:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "monolog/monolog",
|
||||
@@ -8027,6 +8023,90 @@
|
||||
],
|
||||
"time": "2026-04-10T16:19:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-iconv",
|
||||
"version": "v1.37.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-iconv.git",
|
||||
"reference": "2c5729fd241b4b22f6e4b436bc3354a4f262df57"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/2c5729fd241b4b22f6e4b436bc3354a4f262df57",
|
||||
"reference": "2c5729fd241b4b22f6e4b436bc3354a4f262df57",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"provide": {
|
||||
"ext-iconv": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-iconv": "For best performance"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"thanks": {
|
||||
"url": "https://github.com/symfony/polyfill",
|
||||
"name": "symfony/polyfill"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Iconv\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nicolas Grekas",
|
||||
"email": "p@tchwork.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"description": "Symfony polyfill for the Iconv extension",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"iconv",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/polyfill-iconv/tree/v1.37.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://symfony.com/sponsor",
|
||||
"type": "custom"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/fabpot",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://github.com/nicolas-grekas",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2026-04-10T16:19:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-intl-grapheme",
|
||||
"version": "v1.38.1",
|
||||
|
||||
Reference in new issue
Block a user