diff --git a/app/Console/Commands/GetAssets.php b/app/Console/Commands/GetAssets.php new file mode 100644 index 000000000..a755d81ed --- /dev/null +++ b/app/Console/Commands/GetAssets.php @@ -0,0 +1,58 @@ +charId = 93738489; $job->corpId = 98287666; $job->structure = $structure; - JobProcessStructure::dispatch($job)->onQueue('default'); + ProcessStructureJob::dispatch($job)->onQueue('default'); } } while ($currentPage < $totalPages); diff --git a/app/Jobs/ProcessStocksJob.php b/app/Jobs/ProcessAssetsJob.php similarity index 73% rename from app/Jobs/ProcessStocksJob.php rename to app/Jobs/ProcessAssetsJob.php index 494637543..b5cc89ffc 100644 --- a/app/Jobs/ProcessStocksJob.php +++ b/app/Jobs/ProcessAssetsJob.php @@ -8,7 +8,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; -class ProcessStocksJob implements ShouldQueue +class ProcessAssetsJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; @@ -19,7 +19,7 @@ class ProcessStocksJob implements ShouldQueue */ public function __construct() { - $this->connection = 'redis'; + // } /** @@ -29,9 +29,6 @@ class ProcessStocksJob implements ShouldQueue */ public function handle() { - //Delcare the class variable we need for processing - $stock = new StructureStockHelper; - - + // } } diff --git a/app/Library/Structures/JumpBridgeFuel.php b/app/Library/Structures/JumpBridgeFuel.php deleted file mode 100644 index 0571049e4..000000000 --- a/app/Library/Structures/JumpBridgeFuel.php +++ /dev/null @@ -1,154 +0,0 @@ -charId = $charId; - $this->corpId = $corpId; - - //Set ESI Scopes true or false whether we have the correct ones - $esi = new Esi(); - if($esi->HaveEsiScope($this->charId, 'esi-assets.read_corporation_assets.v1') && - $esi->HaveEsiScope($this->charId, 'esi-corporations.read_structures.v1')) { - $this->hasScopes = true; - } else { - $this->hasScopes = false; - } - } - - public function GetCorrrectScopes() { - return $this->hasScopes; - } - - public function GetStructureFuel() { - - } - - private function GetStructures($charId, $corpId) { - //Delcare the data array for returning - $data = array(); - - //Get a list of structures. - $config = config('esi'); - //Get the token from the database - $token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']); - //Setup the ESI authentication container - $authentication = new EsiAuthentication([ - 'client_id' => $config['client_id'], - 'secret' => $config['secret'], - 'refresh_token' => $token[0]->refresh_token, - - ]); - //Setup the ESI authentication container - $esi = new Eseye($authentication); - - //set the ESI version we need to work with - $esi->setVersion('v3'); - - //Set our current page - $currentPage = 1; - //Set our default total pages, and will refresh this later - $totalPages = 1; - - //If more than one page is found, decode the first, then the second - do { - //Try to gather the structures from ESI - try { - $structures = $esi->page($currentPage) - ->invoke('get', '/corporations/{corporation_id}/structures/', [ - 'corporation_id' => $corpId, - ]); - } catch(RequestFailedException $e) { - return null; - } - - //Set the actual total pages after we performed the esi call - $totalPages = $structures->pages; - - foreach($structures as $structure) { - if($structure->type_id == 35841) { - $data = array_push($data, $structure); - } - } - } while ($currentPage < $totalPages); - - //Add structures to a data array for just jump bridge type, and return the data array - return $data; - } - - private function GetAssets($corpId, $structures) { - //Delcare the data array for returning - $data = array(); - - //Get a list of structures. - $config = config('esi'); - //Get the token from the database - $token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']); - //Setup the ESI authentication container - $authentication = new EsiAuthentication([ - 'client_id' => $config['client_id'], - 'secret' => $config['secret'], - 'refresh_token' => $token[0]->refresh_token, - ]); - //Setup the ESI authentication container - $esi = new Eseye($authentication); - - //set the ESI version we need to work with - $esi->setVersion('v3'); - - //Set our current page - $currentPage = 1; - //Set our default total pages, and will refresh this later - $totalPages = 1; - - //If more than one page is available we want to get all the pages - do { - try { - //Try to pull the data from ESI - $assets = $esi->page($currentPage) - ->invoke('get', '/corporations/{corporation_id}/assets/', [ - 'corporation_id' => $corpId, - ]); - } catch(RequestFailedException $e) { - //If ESI fails, we just return null - return null; - } - - //Set the total number of pages - $totalPages = $assets->pages; - - //For each entry, we only want to save the entries - foreach($assets as $asset) { - if($asset->type_id == 16273) { - //If the type id is correct then push the data onto the array - $data = array_push($data, $asset); - } - } - - } while($currentPage < $totalPages); - - //Return the list of assets, the structure the asset is in, and the division, - //to the calling function - return $data; - } - - -} - -?> \ No newline at end of file diff --git a/app/Models/Jobs/JobProcessAssets.php b/app/Models/Jobs/JobProcessAssets.php new file mode 100644 index 000000000..1ddb68564 --- /dev/null +++ b/app/Models/Jobs/JobProcessAssets.php @@ -0,0 +1,10 @@ +