From 755aad8da6a88be10b79a18427ad9e23f8ab8939 Mon Sep 17 00:00:00 2001 From: Refringe Date: Thu, 3 Oct 2024 16:11:26 -0400 Subject: [PATCH] Hub Import Mod Removal Removes mods that are no longer on the hub. --- app/Jobs/ImportHubDataJob.php | 16 ++++++++++++++++ config/horizon.php | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/Jobs/ImportHubDataJob.php b/app/Jobs/ImportHubDataJob.php index c429512..669a31b 100644 --- a/app/Jobs/ImportHubDataJob.php +++ b/app/Jobs/ImportHubDataJob.php @@ -51,6 +51,9 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue $this->importMods(); $this->importModVersions(); + // Remove mods that are no longer on the hub. + $this->removeDeletedMods(); + // Ensure that we've disconnected from the Hub database, clearing temporary tables. DB::connection('mysql_hub')->disconnect(); @@ -965,6 +968,19 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue }, 'versionID'); } + /** + * Remove mods that are no longer on the Hub. + */ + private function removeDeletedMods(): void + { + $mods = Mod::select('hub_id')->all(); + foreach ($mods as $mod) { + if (DB::connection('mysql_hub')->table('filebase1_file')->where('fileID', $mod->hub_id)->doesntExist()) { + $mod->delete(); + } + } + } + /** * The job failed to process. */ diff --git a/config/horizon.php b/config/horizon.php index b3a3771..f8cde95 100644 --- a/config/horizon.php +++ b/config/horizon.php @@ -207,7 +207,7 @@ return [ 'maxJobs' => 0, 'memory' => 256, 'tries' => 1, - 'timeout' => 1500, // 25 Minutes + 'timeout' => 2700, // 45 Minutes 'nice' => 0, ], ],