new sofaskore task add date to select in statistics
This commit is contained in:
1 parent
f8e6f8183b
commit
5f4a788927
18 files changed
+207
-281
No files matched your search
@@ -15,7 +15,7 @@ class LoadStatisticFixturesMatchOptions
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $val) {
|
||||
$arr[$val->id] = $val->home->name.' vs '.$val->away->name;
|
||||
$arr[$val->id] = $val->starttime->format('Y-m-H H:i') . ' - ' . $val->home->name . ' vs ' . $val->away->name;
|
||||
}
|
||||
|
||||
return $arr;
|
||||
|
||||
@@ -16,16 +16,11 @@ ini_set('magic_quotes_runtime', false);
|
||||
|
||||
class Sofascore
|
||||
{
|
||||
|
||||
public static string $grapper_path;
|
||||
|
||||
public static function switch()
|
||||
{
|
||||
self::$grapper_path = app_path('/Console/Commands/Grapper/Sofascore/Grapped/');
|
||||
|
||||
$function = Nuh::$options['fun'];
|
||||
|
||||
switch($function){
|
||||
switch ($function) {
|
||||
case 1:
|
||||
PlayerPerSeason::run();
|
||||
break;
|
||||
@@ -50,7 +45,7 @@ class Sofascore
|
||||
case 8:
|
||||
TaskConfig::end();
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
Notice::note('id not valid', 'br', 1);
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
*/*
|
||||
Binary file not shown.
Binary file not shown.
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Console\Commands\Grapper\Sofascore;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\CurlSofa;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\LoadDays;
|
||||
use App\Console\Commands\Grapper\Sofascore\Helper\Sleeper;
|
||||
@@ -81,7 +80,7 @@ class Grapper
|
||||
$event_grapped['name'] = $event->homeTeam['name'] . ' vs ' . $event->awayTeam['name'];
|
||||
$event_grapped['url'] = $url;
|
||||
|
||||
$folder = Sofascore::$grapper_path . $day . '/' . $event['tournament']['slug'] . '/' . $event['slug'];
|
||||
$folder = storage_path('sofascore_data') . $day . '/' . $event['tournament']['slug'] . '/' . $event['slug'];
|
||||
|
||||
File::makeDirectory($folder, 0775, true, true);
|
||||
|
||||
|
||||
@@ -30,13 +30,25 @@ class LoadDays
|
||||
|
||||
switch ($task->mode) {
|
||||
|
||||
case 'yesterday':
|
||||
case 'auto_updater':
|
||||
$dates[] = [
|
||||
'day' => Carbon::now()->subDay()->format('Y-m-d'),
|
||||
'slug' => $task->sport->ss_slug,
|
||||
'sport_id' => $task->sport_id,
|
||||
'run_repeatedly' => $task->run_repeatedly,
|
||||
];
|
||||
$dates[] = [
|
||||
'day' => Carbon::now()->subDays(2)->format('Y-m-d'),
|
||||
'slug' => $task->sport->ss_slug,
|
||||
'sport_id' => $task->sport_id,
|
||||
'run_repeatedly' => $task->run_repeatedly,
|
||||
];
|
||||
$dates[] = [
|
||||
'day' => Carbon::now()->subDays(3)->format('Y-m-d'),
|
||||
'slug' => $task->sport->ss_slug,
|
||||
'sport_id' => $task->sport_id,
|
||||
'run_repeatedly' => $task->run_repeatedly,
|
||||
];
|
||||
break;
|
||||
|
||||
case 'date':
|
||||
|
||||
@@ -9,7 +9,7 @@ class Sleeper
|
||||
if ($langsam) {
|
||||
$sleep = rand(3000000, 6000000);
|
||||
} else {
|
||||
$sleep = rand(500000, 1000000);
|
||||
$sleep = rand(500000, 100000);
|
||||
}
|
||||
usleep($sleep);
|
||||
}
|
||||
|
||||
@@ -15,34 +15,34 @@ class SendMail
|
||||
$debug = Nuh::$options['d'] ?? 0;
|
||||
|
||||
$days = LoadDays::load();
|
||||
|
||||
|
||||
foreach ($days as $d) {
|
||||
|
||||
$day = $d['day'];
|
||||
|
||||
$zip_file = storage_path('zip_sofascore_data').'/'.$day.'.zip';
|
||||
$zip_file = storage_path('sofascore_data') . '/' . $day . '.zip';
|
||||
|
||||
if(File::exists($zip_file)){
|
||||
if (File::exists($zip_file)) {
|
||||
|
||||
if($debug){
|
||||
Notice::note('Mail send' .$day);
|
||||
if ($debug) {
|
||||
Notice::note('Mail send' . $day);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Mail::send([], [], function ($message) use ($day, $zip_file) {
|
||||
|
||||
$message->to('hermann.telser@gmail.com', 'sofa archive '.$day)
|
||||
->cc('ubaldo.perrucci@gmail.com', 'sofa archive '.$day)
|
||||
$message->to('hermann.telser@gmail.com', 'sofa archive ' . $day)
|
||||
->cc('ubaldo.perrucci@gmail.com', 'sofa archive ' . $day)
|
||||
->subject("sofa archive $day")
|
||||
->attach($zip_file, [
|
||||
'mime' => 'application/x-zip-compressed',
|
||||
'as' => 'sofa archive '.$day.'.zip',
|
||||
'as' => 'sofa archive ' . $day . '.zip',
|
||||
]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if($debug){
|
||||
if ($debug) {
|
||||
Notice::note('Mail send', 'g');
|
||||
}
|
||||
}
|
||||
|
||||
+9
-2
@@ -2,16 +2,23 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\RelationManagers\SofaScoreTaskTournamentsRelationManager;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\SofaScoreTaskResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Guava\FilamentModalRelationManagers\Actions\RelationManagerAction;
|
||||
|
||||
class EditSofaScoreTask extends EditRecord
|
||||
{
|
||||
protected static string $resource = SofaScoreTaskResource::class;
|
||||
|
||||
protected function getFormActions(): array
|
||||
{
|
||||
return [
|
||||
$this->getSaveFormAction(),
|
||||
$this->getCancelFormAction()->label('Close Task Manager'), // Renames the button
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\RelationManagers\SofaScoreTaskTournamentsRelationManager;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\SofaScoreTaskResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Guava\FilamentModalRelationManagers\Actions\RelationManagerAction;
|
||||
|
||||
class ListSofaScoreTasks extends ListRecords
|
||||
{
|
||||
|
||||
+5
-5
@@ -14,7 +14,7 @@ class SofaScoreTaskForm
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->columns(1)
|
||||
->columns(5)
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->required(),
|
||||
@@ -29,18 +29,18 @@ class SofaScoreTaskForm
|
||||
->allowHtml()
|
||||
->required()
|
||||
->options([
|
||||
'yesterday' => '<span class="text-amber-600">Every yesterday</span>',
|
||||
'auto_updater' => '<span class="text-green-600">Grap last 3 days</span>',
|
||||
'date' => '<span class="text-blue-600">Grap a date</span>',
|
||||
'range' => '<span class="text-green-600">Grap a date range</span>',
|
||||
'range' => '<span class="text-amber-600">Grap a date range</span>',
|
||||
]),
|
||||
DatePicker::make('day_from')
|
||||
->required()
|
||||
->native()
|
||||
->visible(fn (Get $get): bool => in_array($get('mode'), ['date', 'range'])),
|
||||
->visible(fn(Get $get): bool => in_array($get('mode'), ['date', 'range'])),
|
||||
DatePicker::make('day_to')
|
||||
->required()
|
||||
->native()
|
||||
->visible(fn (Get $get): bool => $get('mode') === 'range'),
|
||||
->visible(fn(Get $get): bool => $get('mode') === 'range'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Pages\EditSofaScoreTask;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Pages\ListSofaScoreTasks;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\RelationManagers\SofaScoreTaskTournamentsRelationManager;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Schemas\SofaScoreTaskForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Tables\SofaScoreTasksTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
@@ -26,6 +28,12 @@ class SofaScoreTaskResource extends Resource
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'SofaScore';
|
||||
|
||||
protected function isReadOnly(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return SofaScoreTaskForm::configure($schema);
|
||||
@@ -45,6 +53,14 @@ class SofaScoreTaskResource extends Resource
|
||||
{
|
||||
return [
|
||||
'index' => ListSofaScoreTasks::route('/'),
|
||||
'edit' => EditSofaScoreTask::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
SofaScoreTaskTournamentsRelationManager::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
+1
-9
@@ -2,14 +2,12 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\Tables;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\SofaScoreTasks\RelationManagers\SofaScoreTaskTournamentsRelationManager;
|
||||
use App\Models\SofaScoreTask;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\ToggleColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Guava\FilamentModalRelationManagers\Actions\RelationManagerAction;
|
||||
|
||||
class SofaScoreTasksTable
|
||||
{
|
||||
@@ -40,7 +38,7 @@ class SofaScoreTasksTable
|
||||
TextColumn::make('mode')
|
||||
->label('Grapping dates')
|
||||
->formatStateUsing(fn(string $state, $record): string => match ($state) {
|
||||
'yesterday' => 'Every yesterday',
|
||||
'auto_updater' => 'Last 3 days',
|
||||
'date' => $record->day_from,
|
||||
'range' => $record->day_from . ' <=> ' . $record->day_to,
|
||||
}),
|
||||
@@ -56,12 +54,6 @@ class SofaScoreTasksTable
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
RelationManagerAction::make()
|
||||
->icon('phosphor-trophy-fill')
|
||||
->iconButton()
|
||||
->modalHeading('Add tournaments to sofascore grapper task')
|
||||
->relationManager(SofaScoreTaskTournamentsRelationManager::make())
|
||||
->compact(),
|
||||
EditAction::make()->iconButton()
|
||||
->icon('phosphor-pen-fill'),
|
||||
]);
|
||||
|
||||
+13
-12
@@ -2,27 +2,27 @@
|
||||
|
||||
namespace App\Utilities;
|
||||
|
||||
use App\Console\Commands\Grapper\Sofascore;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
use ZipArchive;
|
||||
|
||||
class ZipFolder
|
||||
{
|
||||
public static function create(string $day){
|
||||
|
||||
$zipFilePath = storage_path('zip_sofascore_data').'/'.$day.'.zip';
|
||||
public static function create(string $day)
|
||||
{
|
||||
|
||||
$path = Sofascore::$grapper_path.$day;
|
||||
$zipFilePath = storage_path('sofascore_data') . '/' . $day . '.zip';
|
||||
|
||||
$path = storage_path('sofascore_data') . $day;
|
||||
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
|
||||
|
||||
if(is_dir($path)){
|
||||
if (is_dir($path)) {
|
||||
|
||||
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
|
||||
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (!$file->isDir()) {
|
||||
$filePath = $file->getRealPath();
|
||||
@@ -37,13 +37,14 @@ class ZipFolder
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_tree(string $dir, &$results = array()){
|
||||
public static function get_tree(string $dir, &$results = array())
|
||||
{
|
||||
$files = scandir($dir);
|
||||
foreach($files as $value){
|
||||
$path = realpath($dir.DIRECTORY_SEPARATOR.$value);
|
||||
if(!is_dir($path)) {
|
||||
foreach ($files as $value) {
|
||||
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
|
||||
if (!is_dir($path)) {
|
||||
$results[] = $path;
|
||||
} else if($value != "." && $value != "..") {
|
||||
} else if ($value != "." && $value != "..") {
|
||||
self::get_tree($path, $results);
|
||||
$results[] = $path;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user