diff --git a/app/Console/Commands/Grap.php b/app/Console/Commands/Grap.php index b24d2507..1761092e 100644 --- a/app/Console/Commands/Grap.php +++ b/app/Console/Commands/Grap.php @@ -38,28 +38,28 @@ class Grap extends Command self::$options['base_url'] = 'https://www.sofascore.com/'; if (! self::$options['id']) { - $txt = 'PARAMETERS'.PHP_EOL; - $txt .= '--d debug'.PHP_EOL; - $txt .= '--r restart range'.PHP_EOL; - $txt .= '--f force'.PHP_EOL; - $txt .= '--R read file'.PHP_EOL; - $txt .= '--S save to file'.PHP_EOL; - $txt .= '--folder'.PHP_EOL; - $txt .= '-----------------------------------------------------------'.PHP_EOL; - $txt .= 'FUNCTION'.PHP_EOL; - $txt .= ' 1 grapper DAILY & subDays ( default 3)'.PHP_EOL; - $txt .= ' 2 grapper DATE'.PHP_EOL; - $txt .= ' 3 grapper RANGE'.PHP_EOL; - $txt .= ' 4 grapper ROSE'.PHP_EOL; - $txt .= ' 5 import to excel from folder'.PHP_EOL; - $txt .= ' 6 playeer/season'.PHP_EOL; - $txt .= ' 7 settings to local'.PHP_EOL; - $txt .= ' 11 move SQL'.PHP_EOL; - $txt .= ' 12 testing url for grapping'.PHP_EOL; + $txt = 'PARAMETERS' . PHP_EOL; + $txt .= '--d debug' . PHP_EOL; + $txt .= '--r restart range' . PHP_EOL; + $txt .= '--f force' . PHP_EOL; + $txt .= '--R read file' . PHP_EOL; + $txt .= '--S save to file' . PHP_EOL; + $txt .= '--folder' . PHP_EOL; + $txt .= '-----------------------------------------------------------' . PHP_EOL; + $txt .= 'FUNCTION' . PHP_EOL; + $txt .= ' 1 grapper DAILY & subDays ( default 3)' . PHP_EOL; + $txt .= ' 2 grapper DATE' . PHP_EOL; + $txt .= ' 3 grapper RANGE' . PHP_EOL; + $txt .= ' 4 grapper ROSE' . PHP_EOL; + $txt .= ' 5 import to excel from folder' . PHP_EOL; + $txt .= ' 6 playeer/season' . PHP_EOL; + $txt .= ' 7 settings to local' . PHP_EOL; + $txt .= ' 11 move SQL' . PHP_EOL; + $txt .= ' 12 testing url for grapping' . PHP_EOL; Notice::note($txt, 'b', 1); } - Notice::note('Task Id '.self::$options['id'], 'gb'); + Notice::note('Task Id ' . self::$options['id'], 'gb'); switch (self::$options['id']) { @@ -86,7 +86,7 @@ class Grap extends Command // RANGE SetStorage::set(3); - Grapper::load(3); + // Grapper::load(3); MakeExcel::create(); diff --git a/app/Console/Commands/Grapper/Sofascore/Helper/SetStorage.php b/app/Console/Commands/Grapper/Sofascore/Helper/SetStorage.php index 63b2fb08..88f2c66d 100644 --- a/app/Console/Commands/Grapper/Sofascore/Helper/SetStorage.php +++ b/app/Console/Commands/Grapper/Sofascore/Helper/SetStorage.php @@ -13,6 +13,8 @@ class SetStorage { $debug = Grap::$options['d']; + $force = Grap::$options['f']; + $folder = Grap::$options['folder'] ?? ''; $day = Grap::$options['day'] == 0 ? 2 : Grap::$options['day']; @@ -36,8 +38,8 @@ class SetStorage break; case 3: Grap::$storage = $sofascore_data . 'range/' . $storage_name; - Grap::$folder = $storage_name . '-' . $task->day_from . '-' . $task->day_to; - Grap::$excel = $sofascore_data . 'range/' . $storage_name; + Grap::$folder = $storage_name; + Grap::$excel = $sofascore_data . 'range/' . $storage_name . '.xlsx'; break; case 4: Grap::$storage = $sofascore_data . $storage_name; @@ -57,7 +59,9 @@ class SetStorage if ($debug) { Notice::note(Grap::$folder, 'g'); // Notice::note(Grap::$storage); - sleep(4); + if (!$force) { + sleep(4); + } } } } diff --git a/app/Console/Commands/Grapper/Sofascore/MakeExcel.php b/app/Console/Commands/Grapper/Sofascore/MakeExcel.php index 3cca9cef..b6a7d5b2 100644 --- a/app/Console/Commands/Grapper/Sofascore/MakeExcel.php +++ b/app/Console/Commands/Grapper/Sofascore/MakeExcel.php @@ -13,8 +13,6 @@ class MakeExcel { public static $max = 1000; - public static $filesToMail = []; - public static function create() { ini_set('memory_limit', -1); @@ -25,7 +23,7 @@ class MakeExcel Notice::note("Make Excel"); } - $files = ReadDir::get_tree(Grap::$excel); + $files = ReadDir::get_tree(Grap::$storage); $files = array_chunk(FileType::filter($files), self::$max); @@ -48,9 +46,8 @@ class MakeExcel $to = $key * self::$max + $has; } - $filename = Grap::$folder . '-' . $from . '-' . $to . '.xlsx'; $spreadsheet = new Spreadsheet; - $spreadsheet->getProperties()->setTitle($filename); + $spreadsheet->getProperties()->setTitle(Grap::$excel); $activeWorksheet = $spreadsheet->getActiveSheet(); $column = 1; @@ -72,9 +69,7 @@ class MakeExcel $spreadsheet->setActiveSheetIndex(0); $writer = IOFactory::createWriter($spreadsheet, 'Xlsx'); - $writer->save(Grap::$storage . '/' . $filename); - - self::$filesToMail[] = Grap::$storage . '/' . $filename; + $writer->save(Grap::$excel); } } } diff --git a/app/Filament/Widgets/Data/LoadEvents/LoadEventsAverages.php b/app/Filament/Widgets/Data/LoadEvents/LoadEventsAverages.php index 545b26dd..3ef6e875 100644 --- a/app/Filament/Widgets/Data/LoadEvents/LoadEventsAverages.php +++ b/app/Filament/Widgets/Data/LoadEvents/LoadEventsAverages.php @@ -11,22 +11,27 @@ class LoadEventsAverages public static function load(array &$data, array $filter, array $labels, array $events) { $tournament_id = (int) $filter['league_id'] ?? 0; - $team_position = $filter['team_position']; - $team_id = (int) $filter['team_id'] ?? 0; - $statistic_type = $filter['statistic_type'] ?? 'gls'; - $season = $filter['season'] ?? 0; - $season_or_date = $filter['season_or_date'] ?? 'season'; + $start = $filter['start_date'] ?? 0; + $end = $filter['end_date'] ?? 0; if ($season_or_date != 'season') $season = 0; + else { + $end = 0; + $start = 0; + } $res = StatistikoEvent::where('league_id', $tournament_id) - ->when($season, function ($query) use ($season) { + ->when($start, function ($query) use ($start) { + return $query->whereDate('starttime', '>=', $start); + })->when($end, function ($query) use ($end) { + return $query->whereDate('starttime', '<=', $end); + })->when($season, function ($query) use ($season) { return $query->whereIn('season', $season); }) ->orderBy('starttime', 'ASC')