From c6339973b06b718fc47896a672f27bfa0a3da449 Mon Sep 17 00:00:00 2001 From: Artem Otliaguzov Date: Tue, 20 Aug 2024 13:59:19 +0200 Subject: [PATCH] return RateLimiter after test --- app/Jobs/RunMdaScript.php | 5 +++-- app/Providers/AppServiceProvider.php | 9 ++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Jobs/RunMdaScript.php b/app/Jobs/RunMdaScript.php index 43318e2..a68cc4a 100644 --- a/app/Jobs/RunMdaScript.php +++ b/app/Jobs/RunMdaScript.php @@ -3,6 +3,7 @@ namespace App\Jobs; use App\Models\Federation; +use App\Services\FederationService; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -71,11 +72,11 @@ public function handle(): void * Get the middleware the job should pass through. * * @return array + * @throws \Exception */ public function middleware(): array { - $diskName = config('storageCfg.name'); - $pathToDirectory = Storage::disk($diskName)->path($this->federation->name); + $pathToDirectory = FederationService::getFederationFolder($this->federation); $lockKey = 'directory-'.md5($pathToDirectory).'-lock'; return [ diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index c987c75..6e785f2 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -4,6 +4,7 @@ use App\Jobs\RunMdaScript; use App\Services\CategoryTagService; +use App\Services\FederationService; use App\Services\HfdTagService; use App\Services\RsTagService; use Illuminate\Cache\RateLimiting\Limit; @@ -47,13 +48,11 @@ public function boot() // Mail::alwaysTo('foo@example.org'); Model::preventLazyLoading(); } - //TODO comment this for testing part - /* RateLimiter::for('mda-run-limit', function (RunMdaScript $job) { - $diskName = config('storageCfg.name'); - $pathToDirectory = Storage::disk($diskName)->path($job->federation->name); + RateLimiter::for('mda-run-limit', function (RunMdaScript $job) { + $pathToDirectory = FederationService::getFederationFolder($job->federation); $lockKey = 'directory-'.md5($pathToDirectory).'-lock'; return Limit::perMinute(1)->by($lockKey); - });*/ + }); } }