From 3c8059eb1ce7f4a7db6f57a13ae67a67a3b337d1 Mon Sep 17 00:00:00 2001
From: "a.croix" <croix.alexandre@gmail.com>
Date: Wed, 19 May 2021 23:55:56 +0200
Subject: [PATCH] Change processor to set training flag to true juste before
 the training step of the job

---
 app/Jobs/WowaJob.php         | 2 ++
 app/Logging/LogProcessor.php | 9 ++++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/app/Jobs/WowaJob.php b/app/Jobs/WowaJob.php
index cc9c59e..f45925c 100644
--- a/app/Jobs/WowaJob.php
+++ b/app/Jobs/WowaJob.php
@@ -101,6 +101,8 @@ class WowaJob implements ShouldQueue
         $trainer = new Trainer($training_prameters, new SolutionDistance(count($this->evidences[0])));
         $this->wowa->status = Wowa::STATE_RUNNING;
         $this->wowa->save();
+        $processor->setTrainingBooleanTrue();
+        $logg->pushProcessor($processor);
         try {
             $solution = $trainer->run($this->evidences, $this->is_true_alert);
         } catch (\Exception $e) {
diff --git a/app/Logging/LogProcessor.php b/app/Logging/LogProcessor.php
index 8066ce2..180644d 100644
--- a/app/Logging/LogProcessor.php
+++ b/app/Logging/LogProcessor.php
@@ -7,11 +7,13 @@ class LogProcessor
 {
 
     protected $job_id;
+    protected $training_bool = false;
     public function __invoke(array $record): array
     {
         $record['extra'] = [
             'user_id' => auth()->user() ? auth()->user()->id : null,
-            'job_id' => $this->job_id
+            'job_id' => $this->job_id,
+            'training' => $this->training_bool
         ];
         return $record;
     }
@@ -20,4 +22,9 @@ class LogProcessor
     {
         $this->job_id = $job_id;
     }
+
+    public function setTrainingBooleanTrue()
+    {
+        $this->training_bool = true;
+    }
 }
-- 
GitLab