diff --git a/app/Traits/Sofascore/GrappingSofascore.php b/app/Traits/Sofascore/GrappingSofascore.php index 52c2bd34..2b97cdde 100644 --- a/app/Traits/Sofascore/GrappingSofascore.php +++ b/app/Traits/Sofascore/GrappingSofascore.php @@ -132,6 +132,8 @@ trait GrappingSofascore $this->speed = $this->ask_speed(); + $daily_way = $this->select_daily_days(); + if ($this->ask_settings_download()) { $this->settings_to_local(); } @@ -154,39 +156,33 @@ trait GrappingSofascore /** * day 1 */ - // $day = Carbon::now()->subDay()->format('Y-m-d'); + if (in_array($daily_way, [1, 3])) { + $day = Carbon::now()->subDay()->format('Y-m-d'); - // $res = SofaScoreTaskDay::where('grapper_id', (int) $this->task_id)->where('day', $day)->first(); - - // if (! $res) { - // $this->grapped_files = $this->get_tree($this->data_dir . '/' . $day); - - // $this->grap_tournaments_for_day($day); - - // foreach ($this->tournaments_requested as $tournament) { - // $this->get_event($day, $tournament); - // } - // SofaScoreTaskDay::updateOrCreate(['grapper_id' => (int) $this->task_id, 'day' => $day], ['done' => 1]); - // } - /** - * day 5 - */ - $day = Carbon::now()->subDays(5)->format('Y-m-d'); - - $res = SofaScoreTaskDay::where('grapper_id', (int) $this->task_id)->where('day', $day)->first(); - - if (! $res) { - - $this->grapped_files = $this->get_tree($this->data_dir.'/'.$day); + $this->grapped_files = $this->get_tree($this->data_dir . '/' . $day); $this->grap_tournaments_for_day($day); foreach ($this->tournaments_requested as $tournament) { $this->get_event($day, $tournament); } - SofaScoreTaskDay::updateOrCreate(['grapper_id' => (int) $this->task_id, 'day' => $day], ['done' => 1]); } + /** + * day 5 + */ + if (in_array($daily_way, [2, 3])) { + $day = Carbon::now()->subDays(5)->format('Y-m-d'); + + $this->grapped_files = $this->get_tree($this->data_dir . '/' . $day); + + $this->grap_tournaments_for_day($day); + + foreach ($this->tournaments_requested as $tournament) { + $this->get_event($day, $tournament); + } + } + /** * to excel day by day */ @@ -340,6 +336,19 @@ trait GrappingSofascore ); } + protected function select_daily_days(): string + { + return select( + label: 'What days should be grapped?', + scroll: 10, + options: [ + 1 => 'Day 1', + 2 => 'Day 2', + 3 => 'Day 1 & 2', + ] + ); + } + protected function select_day(): string { return text(