From 73e9341ee7a979d83644fc6420727a20e80f6396 Mon Sep 17 00:00:00 2001 From: drkthunder02 Date: Wed, 29 May 2019 00:46:00 -0500 Subject: [PATCH] working on the process assets job --- app/Jobs/ProcessAssetsJob.php | 37 +++++++++++++++++++++++++++++--- app/Jobs/ProcessStructureJob.php | 3 --- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/app/Jobs/ProcessAssetsJob.php b/app/Jobs/ProcessAssetsJob.php index 7890c3d06..d4143a064 100644 --- a/app/Jobs/ProcessAssetsJob.php +++ b/app/Jobs/ProcessAssetsJob.php @@ -47,18 +47,49 @@ class ProcessAssetsJob implements ShouldQueue * * @return void */ - public function __construct() + public function __construct(JobProcessAssets $jpa) { - // + $this->charId = $jpa->charId; + $this->corpId = $jpa->corpId; + $this->page = $jpa->page; + $this->esi = $jpa->esi; + + //Set the connection for the job + $this->connection = 'redis'; } /** * Execute the job. + * The job's task is to get all fo the information for all of the assets in + * a structure and store them in the database. This task can take a few seconds + * therefore we want the Horizon job queue to take care of the request rather + * than the cronjob. * * @return void */ public function handle() { - // + //Get the pages of the asset list + $assets = $this->GePageOfAssets(); + + foreach($assets as $asset) { + + } } + + private function GetPageOfAssets() { + try { + $assets = $this->esi->page($this->page) + ->invoke('get', '/corporations/{corporation_id}/assets/', [ + 'corporation_id' => $this->corpId, + ]); + } catch (RequestFailedException $e) { + Log::critical("Failed to get page of Assets from ESI."); + $assets = null; + } + + return $assets; + } + + } diff --git a/app/Jobs/ProcessStructureJob.php b/app/Jobs/ProcessStructureJob.php index fcac63a33..fc122b378 100644 --- a/app/Jobs/ProcessStructureJob.php +++ b/app/Jobs/ProcessStructureJob.php @@ -70,9 +70,6 @@ class ProcessStructureJob implements ShouldQueue */ public function handle() { - //Declare the structure helper class. - $structureHelper = new StructureHelper(); - //Get the page of structures $structures = $this->GetListOfStructures();