From 5c4b53beeca698ed9449c0ac51f099dde86936c7 Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Thu, 29 Feb 2024 23:25:17 -0500 Subject: [PATCH] [Chore] Refactored InfluxDBv2 data listener (#1272) --- .../WriteCompletedSpeedtest.php} | 17 +++++--------- app/Listeners/Data/InfluxDb2Listener.php | 23 +++++-------------- 2 files changed, 12 insertions(+), 28 deletions(-) rename app/Jobs/{SendDataToInfluxDbV2.php => InfluxDBv2/WriteCompletedSpeedtest.php} (86%) diff --git a/app/Jobs/SendDataToInfluxDbV2.php b/app/Jobs/InfluxDBv2/WriteCompletedSpeedtest.php similarity index 86% rename from app/Jobs/SendDataToInfluxDbV2.php rename to app/Jobs/InfluxDBv2/WriteCompletedSpeedtest.php index 28261db68..ea6328bd8 100644 --- a/app/Jobs/SendDataToInfluxDbV2.php +++ b/app/Jobs/InfluxDBv2/WriteCompletedSpeedtest.php @@ -1,6 +1,6 @@ result = $result; - - $this->settings = $settings; + public function __construct( + public Result $result, + public InfluxDbSettings $settings, + ) { } /** diff --git a/app/Listeners/Data/InfluxDb2Listener.php b/app/Listeners/Data/InfluxDb2Listener.php index 6e00e2376..7903e4b51 100644 --- a/app/Listeners/Data/InfluxDb2Listener.php +++ b/app/Listeners/Data/InfluxDb2Listener.php @@ -3,31 +3,20 @@ namespace App\Listeners\Data; use App\Events\SpeedtestCompleted; -use App\Jobs\SendDataToInfluxDbV2; +use App\Jobs\InfluxDBv2\WriteCompletedSpeedtest; use App\Settings\InfluxDbSettings; -use Illuminate\Contracts\Queue\ShouldQueue; -class InfluxDb2Listener implements ShouldQueue +class InfluxDb2Listener { - public $influxDbSettings; - - /** - * Create the event listener. - * - * @return void - */ - public function __construct() - { - $this->influxDbSettings = new (InfluxDbSettings::class); - } - /** * Handle the event. */ public function handle(SpeedtestCompleted $event): void { - if ($this->influxDbSettings->v2_enabled) { - SendDataToInfluxDbV2::dispatch($event->result, $this->influxDbSettings); + $influxSettings = new InfluxDbSettings(); + + if ($influxSettings->v2_enabled) { + WriteCompletedSpeedtest::dispatch($event->result, $influxSettings); } } }