diff --git a/.env.example b/.env.example index 2f5011e..a99da48 100644 --- a/.env.example +++ b/.env.example @@ -18,7 +18,7 @@ DB_PASSWORD= BROADCAST_DRIVER=log CACHE_DRIVER=file FILESYSTEM_DISK=local -QUEUE_CONNECTION=sync +QUEUE_CONNECTION=database SESSION_DRIVER=file SESSION_LIFETIME=120 diff --git a/app/Http/SymfonyCastDl/SymfonyCastDlService.php b/app/Http/SymfonyCastDl/SymfonyCastDlService.php index 8cb25f0..c13a34a 100644 --- a/app/Http/SymfonyCastDl/SymfonyCastDlService.php +++ b/app/Http/SymfonyCastDl/SymfonyCastDlService.php @@ -2,6 +2,7 @@ namespace App\Http\SymfonyCastDl; +use App\Jobs\GetVideoFileSize; use App\Models\Chapter; use App\Models\Course; use GuzzleHttp\TransferStats; @@ -40,14 +41,13 @@ class SymfonyCastDlService $coursePage = $this->client->get('courses/filtering'); $courses = $this->htmlParser->getCourses($coursePage); - $courses->each(fn($course) => $course->save()); -// $singleCoursePage = $this->client->get($courses[3]->link); + $courses->each->save(); /** @var Course $course */ foreach ($courses as $course) { $singleCoursePage = $this->client->get($course->link); $chapters = $this->htmlParser->getCourseDetails($singleCoursePage, $course->id); -// $chapters->each(fn($chapter) => $this->videoSize($chapter)->save()); - $chapters->each(fn($chapter) => $chapter->save()); + $chapters->each->save(); + $chapters->each(fn($chapter) => GetVideoFileSize::dispatch($chapter->id)); } } diff --git a/app/Jobs/GetVideoFileSize.php b/app/Jobs/GetVideoFileSize.php new file mode 100644 index 0000000..b02559a --- /dev/null +++ b/app/Jobs/GetVideoFileSize.php @@ -0,0 +1,36 @@ + +// $this->videoSize($this->chapter); +// $this->chapter->save(); + $service = new SymfonyCastDlService($htmlParser); + $service->videoSize(Chapter::find($this->chapterId)); + +// dd($this->chapterId); + } +} diff --git a/database/migrations/2022_09_16_054545_create_jobs_table.php b/database/migrations/2022_09_16_054545_create_jobs_table.php new file mode 100644 index 0000000..a786a89 --- /dev/null +++ b/database/migrations/2022_09_16_054545_create_jobs_table.php @@ -0,0 +1,36 @@ +bigIncrements('id'); + $table->string('queue')->index(); + $table->longText('payload'); + $table->unsignedTinyInteger('attempts'); + $table->unsignedInteger('reserved_at')->nullable(); + $table->unsignedInteger('available_at'); + $table->unsignedInteger('created_at'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('jobs'); + } +}; diff --git a/database/migrations/2022_09_16_062657_create_failed_jobs_table.php b/database/migrations/2022_09_16_062657_create_failed_jobs_table.php new file mode 100644 index 0000000..1719198 --- /dev/null +++ b/database/migrations/2022_09_16_062657_create_failed_jobs_table.php @@ -0,0 +1,36 @@ +id(); + $table->string('uuid')->unique(); + $table->text('connection'); + $table->text('queue'); + $table->longText('payload'); + $table->longText('exception'); + $table->timestamp('failed_at')->useCurrent(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('failed_jobs'); + } +};