diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 2c7c4abb0..79be1de34 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -81,7 +81,7 @@ class Kernel extends ConsoleKernel $schedule->job(new FetchMiningTaxesObserversJob) ->timezone('UTC') ->dailyAt('22:00'); - $schedule->job(new FetchMiningTaxesLedgersJob) + $schedule->job(new PreFetchMiningTaxesLedgersJob) ->timezone('UTC') ->dailyAt('20:00'); $schedule->job(new SendMiningTaxesInvoicesJob) diff --git a/app/Jobs/Commands/MiningTaxes/PreFetchMiningTaxesLedgersJob.php b/app/Jobs/Commands/MiningTaxes/PreFetchMiningTaxesLedgersJob.php new file mode 100644 index 000000000..410240066 --- /dev/null +++ b/app/Jobs/Commands/MiningTaxes/PreFetchMiningTaxesLedgersJob.php @@ -0,0 +1,68 @@ +connection = 'redis'; + } + + /** + * Execute the job. + * + * @return void + */ + public function handle() + { + //Get the site configuration which holds some data we need + $config = config('esi'); + //Get the observers from the database + $observers = Observer::all(); + + //For each of the observers, send a job to fetch the mining ledger + foreach($observers as $obs) { + //Dispatch the mining taxes ledger jobs + FetchMiningTaxesLedgersJob::dispatch($config['primary'], $config['corporation'], $obs->observer_id)->onQueue('miningtaxes'); + } + } +}