lots of progress

This commit is contained in:
2025-01-26 21:36:05 +02:00
parent bbd082fd8f
commit 6a014c403c
44 changed files with 976 additions and 104 deletions
@@ -57,6 +57,7 @@ class FetchUpcomingMoviesCommand extends Command
$oldUpcomingIds = UpcomingMovie::all()->pluck('movie_id');
foreach ($upcomingMovies['results'] as $upcomingMovie) {
echo ".";
$movie = $this->process($upcomingMovie);
if ($movie) {
@@ -69,11 +70,13 @@ class FetchUpcomingMoviesCommand extends Command
if (!empty($newUpcomingIds)) {
UpcomingMovie::whereIn('id', $oldUpcomingIds)->delete();
UpcomingMovie::insert($newUpcomingIds);
echo "+";
}
DB::commit();
} catch (\Throwable $e) {
DB::rollBack();
dump($e);
}
}
@@ -86,14 +89,14 @@ class FetchUpcomingMoviesCommand extends Command
return $movie;
}
$itemToFetch = ItemToFetch::where('tmdb_id', $upcomingMovie['id'])->where('type', $type)->first();
$itemToFetch = ItemToFetch::where('tmdb_id', $upcomingMovie['id'])->where('type', ItemToFetch::TYPE_MOVIE)->first();
if ($itemToFetch) {
$this->movieProcessingService->process($itemToFetch, ItemToFetchJobs::JOB_DETAILS);
return Movie::where('tmdb_id', $upcomingMovie['id'])->first();
}
ItemToFetch::create([
$itemToFetch = ItemToFetch::create([
'tmdb_id' => $upcomingMovie['id'],
'type' => ItemToFetch::TYPE_MOVIE,
]);
@@ -107,6 +110,7 @@ class FetchUpcomingMoviesCommand extends Command
'remaining_jobs' => json_encode($jobs),
]);
return null;
$this->movieProcessingService->process($itemToFetch, ItemToFetchJobs::JOB_DETAILS);
return Movie::where('tmdb_id', $upcomingMovie['id'])->first();
}
}