Kaynağa Gözat

refactor: so carrega query de verificacao de 5 dias quando em ambiente de prod

Gustavo Mantovani 2 hafta önce
ebeveyn
işleme
ca86217f59
1 değiştirilmiş dosya ile 8 ekleme ve 7 silme
  1. 8 7
      app/Services/ProviderWithdrawalService.php

+ 8 - 7
app/Services/ProviderWithdrawalService.php

@@ -36,7 +36,7 @@ class ProviderWithdrawalService
                 ProviderWithdrawalStatusEnum::TRANSFERRED,
             ])
             ->sum('gross_amount');
-
+            
         return max(0, $earnings - $withdrawn);
     }
 
@@ -209,9 +209,12 @@ class ProviderWithdrawalService
     {
         return $query
             ->where('code_verified', true)
-            ->whereRaw(
-                $this->scheduleEndedAtExpression().' <= ?',
-                [$this->withdrawalReleaseCutoff()]
+            ->when(
+                ! app()->environment('local', 'development'),
+                fn ($query) => $query->whereRaw(
+                    $this->scheduleEndedAtExpression() . ' <= ?',
+                    [$this->withdrawalReleaseCutoff()]
+                )
             );
     }
 
@@ -239,8 +242,6 @@ class ProviderWithdrawalService
 
     private function withdrawalReleaseCutoff(): string
     {
-        return app()->environment('local', 'development')
-            ? Carbon::now()->format('Y-m-d H:i:s')
-            : Carbon::now()->subDays(5)->format('Y-m-d H:i:s');
+        return Carbon::now()->subDays(5)->format('Y-m-d H:i:s');
     }
 }