diff --git a/app/Console/Commands/ItemProcessing/FetchItemDataCommand.php b/app/Console/Commands/ItemProcessing/FetchItemDataCommand.php index d3ac514..8e58f3f 100644 --- a/app/Console/Commands/ItemProcessing/FetchItemDataCommand.php +++ b/app/Console/Commands/ItemProcessing/FetchItemDataCommand.php @@ -3,6 +3,8 @@ namespace App\Console\Commands\ItemProcessing; use App\Models\ItemToFetch; +use App\Models\ItemToFetchJobs; +use App\Models\Movie; use App\Service\MediaProcessing\FactoryService; use Illuminate\Console\Command; @@ -45,9 +47,16 @@ class FetchItemDataCommand extends Command private function getBatch(string $type, int $batch, string $job) { - return ItemToFetch::whereHas('jobs', function($query) use ($job){ + // if job <> Details the movie in movie table should exist + $query = ItemToFetch::whereHas('jobs', function($query) use ($job){ return $query->where('jobs', '<>', null)->whereRaw('FIND_IN_SET(?, jobs)', [$job]); - })->with(['jobs']) + })->with(['jobs']); + + if ($job !== ItemToFetchJobs::JOB_DETAILS) { + $query = $query->join('movies', 'movies.tmdb_id', '=', 'items_to_fetch.tmdb_id'); + } + + return $query ->where('type', $type) ->take($batch) ->get(); diff --git a/app/Http/Controllers/Forum/CategoriesController.php b/app/Http/Controllers/Forum/CategoriesController.php new file mode 100644 index 0000000..d102f3c --- /dev/null +++ b/app/Http/Controllers/Forum/CategoriesController.php @@ -0,0 +1,11 @@ +tmdb_id."\n"; $this->$methodName($item); } @@ -62,6 +63,8 @@ class MovieProcessingService implements ProcessingInterface $tmdbMovie = $this->moviesApi->getMovie($item->tmdb_id); $tmdbMovie['tmdb_id'] = $tmdbMovie['id']; + Log::channel('fetch_export_items_details')->info("Processing TmdbId ".$tmdbMovie['tmdb_id']); + $movie = Movie::where('tmdb_id', $tmdbMovie['tmdb_id'])->first(); if($movie) { @@ -74,18 +77,22 @@ class MovieProcessingService implements ProcessingInterface $movieId = Movie::create($tmdbMovie); if (!empty($tmdbMovie['belongs_to_collection'])) { + Log::channel('fetch_export_items_details')->info("Processing collections for ".$tmdbMovie['tmdb_id']); $this->processMovieCollection($movieId->id, $tmdbMovie['belongs_to_collection']); } if (!empty($tmdbMovie['genres'])) { + Log::channel('fetch_export_items_details')->info("Processing genres for ".$tmdbMovie['tmdb_id']); $this->processMovieGenres($movieId->id, $tmdbMovie['genres']); } if (!empty($tmdbMovie['production_companies'])) { + Log::channel('fetch_export_items_details')->info("Processing production companies ".$tmdbMovie['tmdb_id']); $this->processProductionCompanies($movieId->id, $tmdbMovie['production_companies']); } if (!empty($tmdbMovie['production_countries'])) { + Log::channel('fetch_export_items_details')->info("Processing production countries ".$tmdbMovie['tmdb_id']); $this->processProductionCountries($movieId->id, $tmdbMovie['production_countries']); } @@ -96,6 +103,8 @@ class MovieProcessingService implements ProcessingInterface { $alternativeTitles = $this->moviesApi->getAlternativeTitles($item->tmdb_id); + Log::channel('fetch_export_items_alternative_titles')->info("Processing TmdbId ".$item->tmdb_id); + if (empty($alternativeTitles) || !isset($alternativeTitles['titles'])) { return; } @@ -123,6 +132,9 @@ class MovieProcessingService implements ProcessingInterface private function getCredits($item) { echo "Credits for TMDBID ".$item->tmdb_id." \n"; + + Log::channel('fetch_export_items_credits')->info("Credits for TMDBID ".$item->tmdb_id); + $tmdbCredits = $this->moviesApi->getCredits($item->tmdb_id); if (empty($tmdbCredits)) { @@ -132,7 +144,13 @@ class MovieProcessingService implements ProcessingInterface $movie = Movie::where('tmdb_id', $item->tmdb_id)->first(); + if (null === $movie) { + echo "No movie for TMDB id ".$item->tmdb_id."\n"; + } + + Log::channel('fetch_export_items_credits')->info("Processing cast for TMDBID ".$item->tmdb_id); $this->processCast($movie, $tmdbCredits['cast'] ?? []); + Log::channel('fetch_export_items_credits')->info("Processing crew for TMDBID ".$item->tmdb_id); $this->processCrew($movie, $tmdbCredits['crew'] ?? []); $this->removeElementFromRemainingJobs($item->tmdb_id, ItemToFetchJobs::JOB_CREDITS); @@ -790,7 +808,7 @@ class MovieProcessingService implements ProcessingInterface private function processCrew($movie, array $crewList) { - if (empty($crewList)) { + if (empty($crewList) || $movie === null) { return; } @@ -826,11 +844,9 @@ class MovieProcessingService implements ProcessingInterface $person = Person::create($personData); } - if ($movie->whereHas('crewList', function ($query) use ($person) { - $query->where('tmdb_id', '=', $person->tmdb_id); + if (!$movie->whereHas('crewList', function ($query) use ($person) { + $query->where('person_id', '=', $person->id); })->exists()) { - return; - } else { $movie->crewList()->attach($person, [ 'known_for_department' => json_encode($crewPerson['known_for_department']), 'job' => $crewPerson['job'], diff --git a/config/logging.php b/config/logging.php index 8d94292..cd1bbde 100644 --- a/config/logging.php +++ b/config/logging.php @@ -126,7 +126,110 @@ return [ 'emergency' => [ 'path' => storage_path('logs/laravel.log'), ], + 'fetch_export' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export.log'), + 'level' => 'info', + ], + 'fetch_export_items_details' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_details.log'), + 'level' => 'info', + ], + + 'fetch_export_items_credits' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_credits.log'), + 'level' => 'info', + ], + 'fetch_export_items_alternative_titles' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_alternative_titles.log'), + 'level' => 'info', + ], + 'fetch_export_items_images' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_images.log'), + 'level' => 'info', + ], + 'fetch_export_items_keywords' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_keywords.log'), + 'level' => 'info', + ], + 'fetch_export_items_releases' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_releases.log'), + 'level' => 'info', + ], + 'fetch_export_items_translations' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_translations.log'), + 'level' => 'info', + ], + 'fetch_export_items_similar' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_similar.log'), + 'level' => 'info', + ], + 'fetch_export_items_recommendations' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_recommendations.log'), + 'level' => 'info', + ], + 'fetch_export_items_reviews' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_reviews.log'), + 'level' => 'info', + ], + 'fetch_export_items_lists' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_lists.log'), + 'level' => 'info', + ], + 'fetch_export_items_changes' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_changes.log'), + 'level' => 'info', + ], + 'fetch_export_items_videos' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_videos.log'), + 'level' => 'info', + ], + 'fetch_export_items_watch_providers' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_watch_providers.log'), + 'level' => 'info', + ], + 'fetch_export_items_external_ids' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_external_ids.log'), + 'level' => 'info', + ], + 'fetch_export_items_content_ratings' => [ + 'driver' => 'stack', + 'channels' => ['daily'], + 'path' => storage_path('logs/fetch_export_items_content_ratings.log'), + 'level' => 'info', + ], ], ]; diff --git a/database/migrations/2025_01_27_190950_create_categories_table.php b/database/migrations/2025_01_27_190950_create_categories_table.php new file mode 100644 index 0000000..7f0b164 --- /dev/null +++ b/database/migrations/2025_01_27_190950_create_categories_table.php @@ -0,0 +1,32 @@ +id(); + $table->integer('order')->default(0); + $table->string('name'); + $table->string('slug'); + $table->string('icon'); + $table->text('description'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('forum_categories'); + } +}; diff --git a/database/migrations/2025_01_27_191007_create_threads_table.php b/database/migrations/2025_01_27_191007_create_threads_table.php new file mode 100644 index 0000000..691ce56 --- /dev/null +++ b/database/migrations/2025_01_27_191007_create_threads_table.php @@ -0,0 +1,33 @@ +id(); + $table->unsignedBigInteger('category_id'); + $table->string('name'); + $table->string('slug'); + $table->string('icon'); + $table->text('description'); + $table->integer('order')->default(0); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('forum_threads'); + } +}; diff --git a/database/migrations/2025_01_27_191019_create_topics_table.php b/database/migrations/2025_01_27_191019_create_topics_table.php new file mode 100644 index 0000000..fa97981 --- /dev/null +++ b/database/migrations/2025_01_27_191019_create_topics_table.php @@ -0,0 +1,31 @@ +id(); + $table->string('name'); + $table->string('slug'); + $table->enum('status', ['open', 'closed', 'sticky']); + $table->unsignedBigInteger('user_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('forum_topics'); + } +}; diff --git a/database/migrations/2025_01_27_191029_create_posts_table.php b/database/migrations/2025_01_27_191029_create_posts_table.php new file mode 100644 index 0000000..a8c70bd --- /dev/null +++ b/database/migrations/2025_01_27_191029_create_posts_table.php @@ -0,0 +1,29 @@ +id(); + $table->text('content'); + $table->unsignedBigInteger('user_id'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('forum_posts'); + } +}; diff --git a/resources/views/layouts/header.blade.php b/resources/views/layouts/header.blade.php index 1ee5e08..8f62a3d 100644 --- a/resources/views/layouts/header.blade.php +++ b/resources/views/layouts/header.blade.php @@ -11,6 +11,7 @@