wip
This commit is contained in:
1 parent
11189ec3d6
commit
2be791d63b
14 files changed
+344
-195
No files matched your search
@@ -2,15 +2,17 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore\CreateZip;
|
||||
use App\Console\Commands\Grapper\Sofascore\DaysTournament;
|
||||
use App\Console\Commands\Grapper\Sofascore\Grapper;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Strings;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\TaskConfig;
|
||||
use App\Console\Commands\Grapper\Sofascore\PlayerPerSeason;
|
||||
use App\Console\Commands\Grapper\Sofascore\SendMail;
|
||||
use App\Console\Commands\Grapper\Sofascore\SettingsToLocal;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Models\SofaScoreTask;
|
||||
use App\Utilities\Notice;
|
||||
use App\Utilities\ZipFolder;
|
||||
|
||||
ini_set('magic_quotes_runtime', false);
|
||||
|
||||
@@ -22,31 +24,40 @@ class Sofascore
|
||||
{
|
||||
$function = Nuh::$options['fun'];
|
||||
|
||||
self::$storage = storage_path('sofascore_data');
|
||||
|
||||
switch ($function) {
|
||||
|
||||
case 1:
|
||||
PlayerPerSeason::run();
|
||||
break;
|
||||
|
||||
case 2:
|
||||
SettingsToLocal::run();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
TaskConfig::start();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
DaysTournament::run();
|
||||
break;
|
||||
|
||||
case 5:
|
||||
self::setStorage();
|
||||
Grapper::load();
|
||||
break;
|
||||
|
||||
case 6:
|
||||
TaskConfig::end();
|
||||
break;
|
||||
|
||||
case 7:
|
||||
CreateZip::run();
|
||||
self::setStorage();
|
||||
ZipFolder::create(self::$storage);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
self::setStorage();
|
||||
SendMail::run();
|
||||
break;
|
||||
|
||||
@@ -54,4 +65,13 @@ class Sofascore
|
||||
Notice::note('id not valid', 'br', 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function setStorage()
|
||||
{
|
||||
$task = Nuh::$options['task'];
|
||||
|
||||
self::$storage = storage_path('sofascore_data') . '/' . Strings::clean(SofaScoreTask::where('id', $task)->value('name'));
|
||||
|
||||
dd(self::$storage);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
use App\Console\Commands\Nuh;
|
||||
use App\Utilities\Notice;
|
||||
use App\Utilities\ZipFolder;
|
||||
|
||||
class CreateZip
|
||||
{
|
||||
public static function run()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
ZipFolder::create(Sofascore::$storage);
|
||||
|
||||
if ($debug) {
|
||||
Notice::note('zips created', 'bb');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,15 @@ use Illuminate\Support\Facades\Log;
|
||||
|
||||
class DaysTournament
|
||||
{
|
||||
/**
|
||||
* a nuh --d --f 67 --fun=4 --task=1
|
||||
*
|
||||
* Ita Serie-A-Saison 23-08-2025 - 24-05-2026
|
||||
* Ger Bundesliga 22-08-2025 – 16-05-2026
|
||||
* Eng Premier league 15-08-2025 - 24-05-2026
|
||||
* Spa La Liga 15-08-2025 - 24-05-2026
|
||||
* Fra Liggue 15-08-2025 - 17-05-2026
|
||||
*/
|
||||
public static function run()
|
||||
{
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
@@ -29,7 +38,7 @@ class DaysTournament
|
||||
$day = $d['day'];
|
||||
$slug = $d['slug'];
|
||||
|
||||
$has = SofaScoreDayTournament::where('day', $day)->first();
|
||||
$has = SofaScoreDayTournament::where('day', $day)->where('sport_id', $sport_id)->first();
|
||||
|
||||
if ($has) {
|
||||
if ($debug) {
|
||||
@@ -154,6 +163,7 @@ class DaysTournament
|
||||
*/
|
||||
SofaScoreDayTournament::updateOrCreate([
|
||||
'tournament_id' => (int) $tournament['id'],
|
||||
'sport_id' => (int) $sport_id,
|
||||
'day' => $day,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,6 @@ class Grapper
|
||||
|
||||
$active_tournaments = SofaScoreTaskTournament::with('tournament')->where('sofa_score_task_id', $task_id)->where('disabled', false)->get();
|
||||
|
||||
// dd($active_tournaments->toArray());
|
||||
|
||||
|
||||
/**
|
||||
* empty grapping folder
|
||||
* empty mailing text
|
||||
@@ -83,10 +80,13 @@ class Grapper
|
||||
|
||||
foreach ($data['events'] as $event) {
|
||||
|
||||
$now = Carbon::now()->subHours(4);
|
||||
$now = Carbon::now()->subHours(3);
|
||||
|
||||
$carbon_day = new Carbon($day);
|
||||
|
||||
$starttime = Carbon::createFromTimestamp($event['startTimestamp']);
|
||||
|
||||
if ($now->greaterThan($starttime)) {
|
||||
if ($now->greaterThan($starttime) && $starttime->isSameDay($carbon_day)) {
|
||||
|
||||
Sleeper::rand(1);
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore\Helper;
|
||||
|
||||
class Strings
|
||||
{
|
||||
|
||||
public static function clean(string $string)
|
||||
{
|
||||
$string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
|
||||
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
|
||||
|
||||
return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -29,7 +29,7 @@ class SofaScoreTaskForm
|
||||
->allowHtml()
|
||||
->required()
|
||||
->options([
|
||||
'auto_updater' => '<span class="text-green-600">Grap last 3 days</span>',
|
||||
'auto_updater' => '<span class="text-green-600">Yesterday</span>',
|
||||
'date' => '<span class="text-blue-600">Grap a date</span>',
|
||||
'range' => '<span class="text-amber-600">Grap a date range</span>',
|
||||
]),
|
||||
|
||||
+33
-2
@@ -2,11 +2,16 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoDetails\Tables;
|
||||
|
||||
use App\Models\StatistikoDetail;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Tables\Columns\Layout\Stack;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
class StatistikoDetailsTable
|
||||
{
|
||||
@@ -38,13 +43,39 @@ class StatistikoDetailsTable
|
||||
// TextColumn::make('team_name')->prefix('Team Name: '),
|
||||
]),
|
||||
])
|
||||
->emptyStateHeading('No double player in details')
|
||||
->contentGrid([
|
||||
'md' => 2,
|
||||
'xl' => 4,
|
||||
])
|
||||
->filters([
|
||||
Filter::make('player_filters')
|
||||
->schema([
|
||||
Checkbox::make('find_double'),
|
||||
])->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
$data['find_double'],
|
||||
function (Builder $query) {
|
||||
$pDetails = StatistikoDetail::pluck('tm_player_id')->toArray();
|
||||
$doublpDetails = array_diff_assoc(
|
||||
$pDetails,
|
||||
array_unique($pDetails)
|
||||
);
|
||||
$query->whereIn('tm_player_id', $doublpDetails)->orderBy('tm_player_id');
|
||||
}
|
||||
);
|
||||
})->indicateUsing(function (array $data): ?string {
|
||||
if (! $data['find_double']) {
|
||||
return null;
|
||||
}
|
||||
return 'Find Double';
|
||||
}),
|
||||
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make()->hiddenLabel(),
|
||||
DeleteAction::make()->hiddenLabel(),
|
||||
EditAction::make()->iconButton(),
|
||||
DeleteAction::make()->iconButton(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+3
@@ -49,6 +49,8 @@ class StatistikoPlayersTable
|
||||
}
|
||||
$arr[$match_id][] = $player_id;
|
||||
}
|
||||
|
||||
return $query->where('match_id', 0);
|
||||
}
|
||||
);
|
||||
})->indicateUsing(function (array $data): ?string {
|
||||
@@ -59,6 +61,7 @@ class StatistikoPlayersTable
|
||||
}),
|
||||
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->emptyStateHeading('No player double in an event')
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton(),
|
||||
|
||||
@@ -131,6 +131,9 @@ class ImportPlayer
|
||||
// ss_playerrating_value,
|
||||
// tm_player_id
|
||||
|
||||
// 'sport_id' => (int) $row[0],
|
||||
// 'match_id' => (int) $row[1],
|
||||
// 'ss_player_id' => (int) $row[2],
|
||||
// 'activeteam_id' => $row[2],
|
||||
// 'playersubstitute_id' => $row[3],
|
||||
// 'goals' => $row[4],
|
||||
|
||||
@@ -9,6 +9,7 @@ class SofaScoreDayTournament extends Model
|
||||
protected $fillable = [
|
||||
'id',
|
||||
'tournament_id',
|
||||
'sport_id',
|
||||
'day',
|
||||
];
|
||||
|
||||
|
||||
@@ -12,11 +12,8 @@ class ZipFolder
|
||||
public static function create(string $path)
|
||||
{
|
||||
|
||||
// $zipFilePath = Sofascore::$storage . '/' . $day . '.zip';
|
||||
|
||||
// $path = Sofascore::$storage . '/' . $day;
|
||||
|
||||
$zipFilePath = $path . '/archive.zip';
|
||||
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
|
||||
|
||||
Reference in new issue
Block a user