This commit is contained in:
salam committed 2026-07-27 16:53:00 +02:00
1 parent 5a6d3585e5
commit 6e14dbd1bc
11 files changed
+123 -67

No files matched your search

@@ -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')) . '/';
@@ -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;
// }
@@ -0,0 +1,39 @@
<?php
namespace App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grapper\Sofascore;
use App\Console\Commands\Grapper\Sofascore\Helper\Strings;
use App\Console\Commands\Grapper\Sofascore\Helper\ZipFolder;
use App\Console\Commands\Nuh;
use Spatie\SimpleExcel\SimpleExcelWriter;
class MakeExcel
{
public static function create()
{
$files = ZipFolder::get_tree(Sofascore::$storage);
$writer = SimpleExcelWriter::create(Sofascore::$storage . '.xlsx');
foreach ($files as $file) {
$name = str_replace('.json', '', basename($file));
$writer->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();
}
}
@@ -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);