diff --git a/app/Console/Commands/Grapper/Sofascore.php b/app/Console/Commands/Grapper/Sofascore.php index 3712dd33..b1be2540 100644 --- a/app/Console/Commands/Grapper/Sofascore.php +++ b/app/Console/Commands/Grapper/Sofascore.php @@ -5,6 +5,7 @@ namespace App\Console\Commands\Grapper; use App\Console\Commands\Grapper\Sofascore\Grapper; use App\Console\Commands\Grapper\Sofascore\Helper\Strings; use App\Console\Commands\Grapper\Sofascore\Helper\ZipFolder; +use App\Console\Commands\Grapper\Sofascore\MakeExcel; use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason; use App\Console\Commands\Grapper\Sofascore\Rose; use App\Console\Commands\Grapper\Sofascore\SendMail; @@ -23,6 +24,8 @@ class Sofascore public static string $archive_name; + public static string $excel_name; + public static string $useragent; public static function switch() @@ -67,6 +70,12 @@ class Sofascore SqlMover::run(); break; + case 8: + self::setStorage(); + + MakeExcel::create(); + break; + default: Notice::note('id not valid', 'br', 1); } @@ -77,6 +86,7 @@ class Sofascore $task = Nuh::$options['task']; self::$storage = storage_path('sofascore_data') . '/'; + // for grapper to start with self::$useragent = 4; $storage_name = Strings::clean(SofaScoreTask::where('id', $task)->value('name')) . '/'; diff --git a/app/Console/Commands/Grapper/Sofascore/Grapper.php b/app/Console/Commands/Grapper/Sofascore/Grapper.php index ce752f98..d7857c40 100644 --- a/app/Console/Commands/Grapper/Sofascore/Grapper.php +++ b/app/Console/Commands/Grapper/Sofascore/Grapper.php @@ -132,7 +132,7 @@ class Grapper * EVENT event *********************************/ - File::put($folder . '/event.json', json_encode($event)); + File::put($folder . '/event.json', json_encode($event, JSON_PRETTY_PRINT)); /********************************* * EVENT statistics @@ -150,7 +150,7 @@ class Grapper $data['id'] = $event_id; - File::put($folder . '/statistics.json', json_encode($data)); + File::put($folder . '/statistics.json', json_encode($data, JSON_PRETTY_PRINT)); $grapped->got_statistics = 1; // } @@ -169,7 +169,7 @@ class Grapper $data['id'] = $event_id; - File::put($folder . '/lineups.json', json_encode($data)); + File::put($folder . '/lineups.json', json_encode($data, JSON_PRETTY_PRINT)); $grapped->got_lineups = 1; // } @@ -188,7 +188,7 @@ class Grapper $data['id'] = $event_id; - File::put($folder . '/odds.json', json_encode($data)); + File::put($folder . '/odds.json', json_encode($data, JSON_PRETTY_PRINT)); $grapped->got_odds = 1; // } @@ -207,7 +207,7 @@ class Grapper $data['id'] = $event_id; - File::put($folder . '/incidents.json', json_encode($data)); + File::put($folder . '/incidents.json', json_encode($data, JSON_PRETTY_PRINT)); $grapped->got_incidents = 1; // } diff --git a/app/Console/Commands/Grapper/Sofascore/MakeExcel.php b/app/Console/Commands/Grapper/Sofascore/MakeExcel.php new file mode 100644 index 00000000..84df6b6f --- /dev/null +++ b/app/Console/Commands/Grapper/Sofascore/MakeExcel.php @@ -0,0 +1,39 @@ +addHeader(['#TEAM# ' . $name]); + + $data = file_get_contents($file); + + $arr = json_decode($data, true); + + if (isset($arr['players']) && is_array($arr['players'])) { + foreach ($arr['players'] as $value) { + if ($value) { + $writer->addRow([$name => json_encode($value)]); + } + } + } + } + + $writer->close(); + } +} diff --git a/app/Console/Commands/Grapper/Sofascore/SqlMover.php b/app/Console/Commands/Grapper/Sofascore/SqlMover.php index 83387563..f88f6f82 100644 --- a/app/Console/Commands/Grapper/Sofascore/SqlMover.php +++ b/app/Console/Commands/Grapper/Sofascore/SqlMover.php @@ -10,24 +10,21 @@ class SqlMover { public static function run() { - // $ligas = [649, 242, 20, 40, 325, 41]; - // $ligas = [5, 9, 19, 26, 13, 99]; - $ligas = [22, 26, 28, 29, 33, 51]; Notice::note('SqlMover', 'b'); - foreach ($ligas as $liga_id) { + $res = StatistikoEvent::pluck('match_id'); + foreach ($res as $match_id) { + $has = StatistikoPlayer::where('match_id', $match_id)->first(); + if (!$has) + Notice::note('StatistikoPlayer missing ' . $match_id, 'br', 1); + } - Notice::note($liga_id, 'b'); - - $res = StatistikoEvent::where('league_id', $liga_id) - ->where('season', '2026') - ->pluck('match_id'); - - foreach ($res as $match_id) { - StatistikoEvent::where('match_id', $match_id)->delete(); - StatistikoPlayer::where('match_id', $match_id)->delete(); - } + $res = StatistikoPlayer::groupBy('match_id')->pluck('match_id'); + foreach ($res as $match_id) { + $has = StatistikoEvent::where('match_id', $match_id)->first(); + if (!$has) + Notice::note('StatistikoEvent missing ' . $match_id, 'br', 1); } Notice::note('done', 'bb', 1); diff --git a/app/Filament/Clusters/StaticData/Resources/StatisticFixtures/Tables/StatisticFixturesTable.php b/app/Filament/Clusters/StaticData/Resources/StatisticFixtures/Tables/StatisticFixturesTable.php index 9166bf6d..9a6c4680 100644 --- a/app/Filament/Clusters/StaticData/Resources/StatisticFixtures/Tables/StatisticFixturesTable.php +++ b/app/Filament/Clusters/StaticData/Resources/StatisticFixtures/Tables/StatisticFixturesTable.php @@ -21,7 +21,7 @@ class StatisticFixturesTable ->columns([ IconColumn::make('sport_id') ->label('') - ->icon(fn (string $state): string => match ($state) { + ->icon(fn(string $state): string => match ($state) { '1' => 'icon-soccerball', '2' => 'icon-icehockey', '3' => 'icon-basketball', @@ -31,16 +31,16 @@ class StatisticFixturesTable ->label('League') ->searchable() ->wrap() - ->tooltip(fn ($record) => $record->league_id) - ->hidden(fn () => auth()->user()->sport_id == 5) - ->description(fn ($record) => ucwords($record->league?->country->name)), - TextColumn::make('starttime')->dateTime('M j, Y h:i')->label('Date'), + ->tooltip(fn($record) => $record->league_id) + ->hidden(fn() => auth()->user()->sport_id == 5) + ->description(fn($record) => ucwords($record->league?->country->name)), + TextColumn::make('starttime')->dateTime('Y-m-d H:i'), TextColumn::make('home.name') - ->tooltip(fn ($record) => $record->home_id) + ->tooltip(fn($record) => $record->home_id) ->color('primary') ->searchable(), TextColumn::make('away.name') - ->tooltip(fn ($record) => $record->away_id) + ->tooltip(fn($record) => $record->away_id) ->color('success') ->searchable(), // TextColumn::make('exp_home')->alignCenter()->numeric(), @@ -49,7 +49,7 @@ class StatisticFixturesTable ]) ->filters([ SelectFilter::make('league_id') - ->options(fn () => LoadStatisticFixturesLeaguesOptions::load(1)) + ->options(fn() => LoadStatisticFixturesLeaguesOptions::load(1)) ->preload() ->searchable() ->columnSpan(2) diff --git a/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Tables/StatistikoEventsTable.php b/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Tables/StatistikoEventsTable.php index df395276..65332c44 100644 --- a/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Tables/StatistikoEventsTable.php +++ b/app/Filament/Clusters/StaticData/Resources/StatistikoEvents/Tables/StatistikoEventsTable.php @@ -50,7 +50,7 @@ class StatistikoEventsTable ->copyable() ->copyMessage('Away team name copied') ->copyMessageDuration(1500), - TextColumn::make('starttime')->dateTime('d.m.Y H:i'), + TextColumn::make('starttime')->dateTime('Y-m-d H:i'), ]) ->filters([ diff --git a/app/Filament/Widgets/ChartEvent.php b/app/Filament/Widgets/ChartEvent.php index bb470979..90d0ebea 100644 --- a/app/Filament/Widgets/ChartEvent.php +++ b/app/Filament/Widgets/ChartEvent.php @@ -63,7 +63,6 @@ class ChartEvent extends ChartWidget position: 'left', generateLabels: (chart) => { const datasets = chart.data.datasets; - alert(datasets) }, }, tooltip: { diff --git a/app/Filament/Widgets/Data/LoadEvents.php b/app/Filament/Widgets/Data/LoadEvents.php index a1da80fa..fea5fd7f 100644 --- a/app/Filament/Widgets/Data/LoadEvents.php +++ b/app/Filament/Widgets/Data/LoadEvents.php @@ -203,13 +203,8 @@ class LoadEvents foreach ($res as $value) { - // dd($value); - - $result_code = (string) $value['result_code']; - - Log::debug($value); - $labels[] = round($value['starttime']->diffInDays(Carbon::now())); + // $labels[] = $value['starttime']->format('Y-m-d H:i'); $playing_date[] = $value['starttime']->format('d. F Y H:i'); diff --git a/app/Filament/Widgets/Data/LoadPerformance.php b/app/Filament/Widgets/Data/LoadPerformance.php index d1f5d6f3..42d21147 100644 --- a/app/Filament/Widgets/Data/LoadPerformance.php +++ b/app/Filament/Widgets/Data/LoadPerformance.php @@ -502,46 +502,62 @@ class LoadPerformance $count_home = 0; $count_away = 0; - for ($i = \count($homes['all']) - 1; $i > 0; $i--) { - if ($homes['all'][$i] == null) { - $count_home++; - } else { - break; + if (isset($homes['all'])) { + for ($i = \count($homes['all']) - 1; $i > 0; $i--) { + if ($homes['all'][$i] == null) { + $count_home++; + } else { + break; + } } } - for ($i = \count($aways['all']) - 1; $i > 0; $i--) { - if ($aways['all'][$i] == null) { - $count_away++; - } else { - break; + if (isset($aways['all'])) { + for ($i = \count($aways['all']) - 1; $i > 0; $i--) { + if ($aways['all'][$i] == null) { + $count_away++; + } else { + break; + } } } $keeps = count($homes['all']) - min($count_home, $count_away) - 1; - $homes['all'] = array_slice($homes['all'], 0, $keeps); - $homes['def'] = array_slice($homes['def'], 0, $keeps); - $homes['att'] = array_slice($homes['att'], 0, $keeps); - $homes['mid'] = array_slice($homes['mid'], 0, $keeps); - $aways['all'] = array_slice($aways['all'], 0, $keeps); - $aways['def'] = array_slice($aways['def'], 0, $keeps); - $aways['att'] = array_slice($aways['att'], 0, $keeps); - $aways['mid'] = array_slice($aways['mid'], 0, $keeps); + if (isset($homes['all'])) { + $homes['all'] = array_slice($homes['all'], 0, $keeps); + $homes['def'] = array_slice($homes['def'], 0, $keeps); + $homes['att'] = array_slice($homes['att'], 0, $keeps); + $homes['mid'] = array_slice($homes['mid'], 0, $keeps); + } + if (isset($aways['all'])) { + $aways['all'] = array_slice($aways['all'], 0, $keeps); + $aways['def'] = array_slice($aways['def'], 0, $keeps); + $aways['att'] = array_slice($aways['att'], 0, $keeps); + $aways['mid'] = array_slice($aways['mid'], 0, $keeps); + } // $labels = array_slice($labels, 0, $keeps); $labels = range(1, $keeps); } - public static function makeAv(array &$arr, $length) + public static function makeAv(array &$arr, int $length) { - $all = isset($arr['all']) ? array_sum($arr['all']) / count($arr['all']) : 1; - $def = isset($arr['def']) ? array_sum($arr['def']) / count($arr['def']) : 1; - $mid = isset($arr['mid']) ? array_sum($arr['mid']) / count($arr['mid']) : 1; - $att = isset($arr['att']) ? array_sum($arr['att']) / count($arr['att']) : 1; - $ret = []; - $ret['all'] = array_fill(0, $length, round($all, 2)); - $ret['def'] = array_fill(0, $length, round($def, 2)); - $ret['mid'] = array_fill(0, $length, round($mid, 2)); - $ret['att'] = array_fill(0, $length, round($att, 2)); + if (isset($arr['all']) && count($arr['all'])) { + $all = isset($arr['all']) ? array_sum($arr['all']) / count($arr['all']) : 1; + $def = isset($arr['def']) ? array_sum($arr['def']) / count($arr['def']) : 1; + $mid = isset($arr['mid']) ? array_sum($arr['mid']) / count($arr['mid']) : 1; + $att = isset($arr['att']) ? array_sum($arr['att']) / count($arr['att']) : 1; + $ret = []; + $ret['all'] = array_fill(0, $length, round($all, 2)); + $ret['def'] = array_fill(0, $length, round($def, 2)); + $ret['mid'] = array_fill(0, $length, round($mid, 2)); + $ret['att'] = array_fill(0, $length, round($att, 2)); + } else { + $ret = []; + $ret['all'] = []; + $ret['def'] = []; + $ret['mid'] = []; + $ret['att'] = []; + } return $ret; } diff --git a/grapper.sh b/grapper.sh index 0343f11f..d0b72f71 100755 --- a/grapper.sh +++ b/grapper.sh @@ -27,11 +27,11 @@ case "$1" in echo "\n⚽ Grapper" php artisan nuh --d --f --ff 67 --fun=3 --task=1 - echo "\n⚽ CreateZip" - php artisan nuh --d --f 67 --fun=4 --task=1 + # echo "\n⚽ CreateZip" + # php artisan nuh --d --f 67 --fun=4 --task=1 - echo "\n⚽ SendMail" - php artisan nuh --d --f 67 --fun=5 --task=1 + # echo "\n⚽ SendMail" + # php artisan nuh --d --f 67 --fun=5 --task=1 echo "\n😎 task done :)" echo "" diff --git a/rosa-2026-07-27.xlsx b/rosa-2026-07-27.xlsx new file mode 100644 index 00000000..43dd3ddc Binary files /dev/null and b/rosa-2026-07-27.xlsx differ