From cb636fd197fb5c15effcdc50637368d158c36c2e Mon Sep 17 00:00:00 2001 From: Refringe Date: Tue, 16 Jul 2024 12:02:52 -0400 Subject: [PATCH] Adds Search Sync Command Adds an artisan app command that handles all of the search set-up and sync needed to get going. `artisan app:search-sync` --- .github/README.md | 5 +++++ app/Console/Commands/SearchSync.php | 23 +++++++++++++++++++++++ app/Jobs/ImportHubData.php | 7 ++----- 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 app/Console/Commands/SearchSync.php diff --git a/.github/README.md b/.github/README.md index f3c839b..aa584bd 100644 --- a/.github/README.md +++ b/.github/README.md @@ -59,6 +59,11 @@ sail artisan migrate:fresh –seed sail artisan horizon ``` +``` +# Sync the local database with the Meilisearch server (requires horizon to be running): +sail artisan app:search-sync +``` + ``` # Install NPM dependencies from within the container: sail npm install diff --git a/app/Console/Commands/SearchSync.php b/app/Console/Commands/SearchSync.php new file mode 100644 index 0000000..9ba27b4 --- /dev/null +++ b/app/Console/Commands/SearchSync.php @@ -0,0 +1,23 @@ + '\App\Models\Mod']); + Artisan::call('scout:import', ['model' => '\App\Models\User']); + + $this->info('The search synchronisation jobs have been added to the queue.'); + } +} diff --git a/app/Jobs/ImportHubData.php b/app/Jobs/ImportHubData.php index faaa631..dbae4fb 100644 --- a/app/Jobs/ImportHubData.php +++ b/app/Jobs/ImportHubData.php @@ -52,11 +52,8 @@ class ImportHubData implements ShouldBeUnique, ShouldQueue // Ensure that we've disconnected from the Hub database, clearing temporary tables. DB::connection('mysql_hub')->disconnect(); - // Reindex the Meilisearch index. - Artisan::call('scout:delete-all-indexes'); - Artisan::call('scout:sync-index-settings'); - Artisan::call('scout:import', ['model' => '\App\Models\Mod']); - Artisan::call('scout:import', ['model' => '\App\Models\User']); + // Re-sync search. + Artisan::call('app:search-sync'); } /**