浏览代码

Update app:hashtag-related-generate command, add existing confirmation

Daniel Supernault 1 年之前
父节点
当前提交
e5e3be0598
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      app/Console/Commands/HashtagRelatedGenerate.php

+ 11 - 0
app/Console/Commands/HashtagRelatedGenerate.php

@@ -9,6 +9,7 @@ use App\Models\HashtagRelated;
 use App\Services\HashtagRelatedService;
 use App\Services\HashtagRelatedService;
 use Illuminate\Contracts\Console\PromptsForMissingInput;
 use Illuminate\Contracts\Console\PromptsForMissingInput;
 use function Laravel\Prompts\multiselect;
 use function Laravel\Prompts\multiselect;
+use function Laravel\Prompts\confirm;
 
 
 class HashtagRelatedGenerate extends Command implements PromptsForMissingInput
 class HashtagRelatedGenerate extends Command implements PromptsForMissingInput
 {
 {
@@ -50,6 +51,16 @@ class HashtagRelatedGenerate extends Command implements PromptsForMissingInput
             exit;
             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 . '...');
         $this->info('Looking up #' . $tag . '...');
 
 
         $tags = StatusHashtag::whereHashtagId($hashtag->id)->count();
         $tags = StatusHashtag::whereHashtagId($hashtag->id)->count();