Move DB queries into jobs, so that the scheduler and artisan command calls doesnt evaluate them until the job is actually run
Some checks failed
Create Docker Image / Build Docker Image (x86_64) (push) Failing after 27s
Create Docker Image / Final Docker Image Manifest (push) Has been skipped

This commit is contained in:
Deon George 2024-07-06 19:56:56 +10:00
parent 844d509834
commit 0dee0292fc
3 changed files with 6 additions and 7 deletions

View File

@ -34,11 +34,11 @@ class BroadbandTraffic extends Command
if ($this->option('supplier')) {
$o = Supplier::where('name','like',$this->option('supplier'))->singleOrFail();
Job::dispatchSync($o);
Job::dispatchSync($o->id);
return;
}
foreach (Supplier::active()->get() as $o)
Job::dispatchSync($o);
Job::dispatchSync($o->id);
}
}

View File

@ -37,9 +37,9 @@ final class BroadbandTraffic implements ShouldQueue
private const traffic = 'broadband';
public function __construct(Supplier $o)
public function __construct(int $sid)
{
$this->o = $o;
$this->o = Supplier::find($sid);
}
/**

View File

@ -3,8 +3,7 @@
use Illuminate\Support\Facades\Schedule;
use App\Jobs\BroadbandTraffic;
use App\Models\Supplier;
Schedule::job(new BroadbandTraffic(Supplier::find(1)))
Schedule::job(new BroadbandTraffic(1))
->timezone('Australia/Melbourne')
->dailyAt('10:00');