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);
@@ -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)
@@ -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([
-1
View File
@@ -63,7 +63,6 @@ class ChartEvent extends ChartWidget
position: 'left',
generateLabels: (chart) => {
const datasets = chart.data.datasets;
alert(datasets)
},
},
tooltip: {
+1 -6
View File
@@ -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');
+44 -28
View File
@@ -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;
}
+4 -4
View File
@@ -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 ""
Binary file not shown.