From e5e3be0598f5ce2a8791f0c4a5c9c7304aeffced Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 17 Nov 2023 22:45:04 -0700 Subject: [PATCH] Update app:hashtag-related-generate command, add existing confirmation --- app/Console/Commands/HashtagRelatedGenerate.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/Console/Commands/HashtagRelatedGenerate.php b/app/Console/Commands/HashtagRelatedGenerate.php index 0613495c9..26fdb8b52 100644 --- a/app/Console/Commands/HashtagRelatedGenerate.php +++ b/app/Console/Commands/HashtagRelatedGenerate.php @@ -9,6 +9,7 @@ use App\Models\HashtagRelated; use App\Services\HashtagRelatedService; use Illuminate\Contracts\Console\PromptsForMissingInput; use function Laravel\Prompts\multiselect; +use function Laravel\Prompts\confirm; class HashtagRelatedGenerate extends Command implements PromptsForMissingInput { @@ -50,6 +51,16 @@ class HashtagRelatedGenerate extends Command implements PromptsForMissingInput exit; } + $exists = HashtagRelated::whereHashtagId($hashtag->id)->exists(); + + if($exists) { + $confirmed = confirm('Found existing related tags, do you want to regenerate them?'); + if(!$confirmed) { + $this->error('Aborting...'); + exit; + } + } + $this->info('Looking up #' . $tag . '...'); $tags = StatusHashtag::whereHashtagId($hashtag->id)->count();