From 9cd0234665ea66dff172d94b9c1b4cb61b1d25b1 Mon Sep 17 00:00:00 2001 From: Fbenas Date: Sun, 21 Jun 2020 17:58:23 +0100 Subject: Improve robustness of all scripts and add more to sync command --- app/Console/Commands/ScrapeFiles.php | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) (limited to 'app/Console/Commands/ScrapeFiles.php') diff --git a/app/Console/Commands/ScrapeFiles.php b/app/Console/Commands/ScrapeFiles.php index 05b7176..e80e9e2 100644 --- a/app/Console/Commands/ScrapeFiles.php +++ b/app/Console/Commands/ScrapeFiles.php @@ -9,35 +9,9 @@ use Illuminate\Support\Facades\Storage; class ScrapeFiles extends Command { - /** - * The name and signature of the console command. - * - * @var string - */ protected $signature = 'scrape:files { directory }'; - - /** - * The console command description. - * - * @var string - */ protected $description = 'Scrape a file for data'; - /** - * Create a new command instance. - * - * @return void - */ - public function __construct() - { - parent::__construct(); - } - - /** - * Execute the console command. - * - * @return mixed - */ public function handle() { $directory = $this->argument('directory'); @@ -48,17 +22,16 @@ class ScrapeFiles extends Command } $files = Storage::disk('local')->files($directory); - - foreach ($files as $file) { - $tournament = 'Six Nations ' . explode('-', explode('.txt', $file)[0])[1]; + $this->info('Starting file: ' . $file); $raw_data = Storage::disk('local')->get($file); + $tournament = 'Six Nations ' . explode('-', explode('.txt', $file)[0])[1]; + $service = new Service(new SixnationsrugbyAdapter($raw_data, $tournament)); $service->save(); } return Command::SUCCESS; } - } -- cgit v1.2.3