visuddhinanda 2 лет назад
Родитель
Сommit
d97eba03cc

+ 4 - 1
app/Console/Commands/MqDiscussion.php

@@ -47,6 +47,7 @@ class MqDiscussion extends Command
         $queue = 'discussion';
         $this->info(" [*] Waiting for {$queue}. To exit press CTRL+C");
         Mq::worker($exchange,$queue,function ($message){
+            $result = 0;
             switch ($message->res_type) {
                 case 'sentence':
                     $sentence = Sentence::where('uid',$message->res_id)->first();
@@ -91,7 +92,7 @@ class MqDiscussion extends Command
                         }
                         $command = '';
                         $whSend = new WebHookSend;
-
+                        $ok = 0;
                         switch ($hook->receiver) {
                             case 'dingtalk':
                                 $ok = $whSend->dingtalk($hook->url,$msgTitle,$msgContent);
@@ -103,6 +104,7 @@ class MqDiscussion extends Command
                                 $ok=2;
                                 break;
                         }
+                        $result += $ok;
                         $this->info("{$command}  ok={$ok}");
                         if($ok===0){
                             WebHook::where('id',$hook->id)->increment('success');
@@ -115,6 +117,7 @@ class MqDiscussion extends Command
                     # code...
                     break;
             }
+            return $result;
         });
 
         return 0;

+ 4 - 14
app/Console/Commands/MqPr.php

@@ -68,6 +68,8 @@ class MqPr extends Command
             $webhooks = WebHook::where('res_id',$message->channel->id)
                             ->where('status','active')
                             ->get();
+
+            $result=0;
             foreach ($webhooks as $key => $hook) {
                 $event = json_decode($hook->event);
                 if(!in_array('pr',$event)){
@@ -87,27 +89,15 @@ class MqPr extends Command
                         break;
                 }
                 $this->info("{$command}  ok={$ok}");
+                $result+=$ok;
                 if($ok===0){
                     WebHook::where('id',$hook->id)->increment('success');
                 }else{
                     WebHook::where('id',$hook->id)->increment('fail');
                 }
             }
+            return $result;
         });
-
-		$callback = function ($msg) {
-            $message = json_decode($msg->body);
-
-
-
-
-		};
-
-		$channel->basic_consume('suggestion', '', false, true, false, false, $callback);
-
-		while ($channel->is_open()) {
-			  $channel->wait();
-		  }
         return 0;
     }
 }

+ 4 - 3
app/Console/Commands/MqProgress.php

@@ -42,7 +42,7 @@ class MqProgress extends Command
         $queue = 'progress';
         $this->info(" [*] Waiting for {$queue}. To exit press CTRL+C");
         Mq::worker($exchange,$queue,function ($message){
-            $ok = $this->call('upgrade:progress',['--book'=>$message->book,
+            $ok1 = $this->call('upgrade:progress',['--book'=>$message->book,
                                             '--para'=>$message->para,
                                             '--channel'=>$message->channel,
                                             ]);
@@ -50,9 +50,10 @@ class MqProgress extends Command
                                                 '--para'=>$message->para,
                                                 '--channel'=>$message->channel,
                                                 ]);
-            $this->info("Received book=".$message->book.' progress='.$ok.' chapter='.$ok2);
+            $this->info("Received book=".$message->book.' progress='.$ok1.' chapter='.$ok2);
+            return $ok1+$ok2;
         });
-
         return 0;
+
     }
 }

+ 1 - 0
app/Console/Commands/MqWbwAnalyses.php

@@ -44,6 +44,7 @@ class MqWbwAnalyses extends Command
         Mq::worker($exchange,$queue,function ($message){
             $ok = $this->call('upgrade:wbw.analyses',['id'=>implode(',',$message)]);
             $this->info("Received count=".count($message).' ok='.$ok);
+            return $ok;
         });
 
         return 0;