Move DB queries into jobs, so that the scheduler and artisan command calls doesnt evaluate them until the job is actually run
This commit is contained in:
parent
844d509834
commit
0dee0292fc
@ -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);
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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');
|
Loading…
Reference in New Issue
Block a user