This commit is contained in:
2019-05-31 00:02:53 -05:00
parent 87f3e767e4
commit 722f034830
4 changed files with 36 additions and 34 deletions

View File

@@ -105,37 +105,26 @@ class GetStructuresCommand extends Command
//Set our default total pages, and we will refresh this later
$totalPages = 1;
//Get the list of structures, and send for processing
do {
//Try to get the ESI data
try {
$structures = $esi->page($currentPage)
->invoke('get', '/corporations/{corporation_id}/structures/', [
'corporation_id' => $corpId,
]);
} catch (RequestFailedException $e) {
Log::critical("Failed to get structure list.");
return null;
}
//Try to get the ESI data
try {
$structures = $esi->page($currentPage)
->invoke('get', '/corporations/{corporation_id}/structures/', [
'corporation_id' => $corpId,
]);
} catch (RequestFailedException $e) {
Log::critical("Failed to get structure list.");
return null;
}
//Update the total pages to go through
if($totalPages == 1) {
$totalPages = $structures->pages;
}
$totalPages = $structures->pages;
//For each structure we retrieve dispatch a job to process it.
foreach($structures as $structure) {
$job = new JobProcessStructure;
$job->charId = $charId;
$job->corpId = $corpId;
$job->structure = $structure;
ProcessStructureJob::dispatch($job)->onQueue('structures');
}
//Update the page counter
$currentPage++;
//Check to see if we need to grab more pages or not.
} while($currentPage <= $totalPages);
for($i = 1; $i <= $totalPages; $i++) {
$job = new JobProcessStructure;
$job->charId = $charId;
$job->corpId = $corpId;
$job->page = $currentPage;
ProcessStructureJob::dispatch($job)->onQueue('structures');
}
//Mark the job as finished
$task->SetStopStatus();

View File

@@ -38,8 +38,6 @@ class ProcessStructureJob implements ShouldQueue
private $charId;
private $corpId;
private $page;
private $esi;
private $structure;
/**
* Create a new job instance.
@@ -50,7 +48,7 @@ class ProcessStructureJob implements ShouldQueue
{
$this->charId = $jps->charId;
$this->corpId = $jps->corpId;
$this->structure = $jps->structure;
$this->page = $jps->page;
//Set the connection for the job
$this->connection = 'redis';
@@ -69,7 +67,11 @@ class ProcessStructureJob implements ShouldQueue
{
$sHelper = new StructureHelper($this->charId, $this->corpId);
$sHelper->ProcessStructure($this->structure);
$structures = $sHelper->GetStructuresByPage($this->page);
foreach($structures as $structure) {
$sHelper->ProcessStructure($structure);
}
//After the job is completed, delete the job
$this->delete();

View File

@@ -61,7 +61,18 @@ class StructureHelper {
//Setup the ESI variable
$esi = new Eseye($authentication);
//Try to get the ESI data
try {
$structures = $esi->page($currentPage)
->invoke('get', '/corporations/{corporation_id}/structures/', [
'corporation_id' => $corpId,
]);
} catch (RequestFailedException $e) {
Log::critical("Failed to get structure list.");
return null;
}
return $structures;
}
public function ProcessStructure($structure) {

View File

@@ -20,6 +20,6 @@ class JobProcessStructure extends Model
protected $fillable = [
'charId',
'corpId',
'structure',
'page',
];
}