assets and structures
This commit is contained in:
@@ -39,7 +39,7 @@ class ExecuteFetchAllianceAssetsCommand extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
FAA::dispatch()->onQueue('default');
|
||||
FAA::dispatch()->onQueue('structures');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class ExecuteFetchAllianceStructuresCommand extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
FAS::dispatch()->onQueue('default');
|
||||
FAS::dispatch()->onQueue('structures');
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,8 @@ class FetchAllianceAssets implements ShouldQueue
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +72,7 @@ class FetchAllianceAssets implements ShouldQueue
|
||||
|
||||
//For each asset retrieved, let's process it.
|
||||
foreach($assets as $a) {
|
||||
ProcessAllianceAssets::dispatch($a)->onQueue('default');
|
||||
ProcessAllianceAssets::dispatch($a)->onQueue('structures');
|
||||
}
|
||||
|
||||
//Increment the current page
|
||||
@@ -145,6 +146,6 @@ class FetchAllianceAssets implements ShouldQueue
|
||||
* @var array
|
||||
*/
|
||||
public function tags() {
|
||||
return ['FetchAllianceAssets', 'AllianceStructures', 'Asset'];
|
||||
return ['FetchAllianceAssets', 'AllianceStructures', 'Assets'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,19 +7,29 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Log;
|
||||
|
||||
//Models
|
||||
use App\Models\Structure\Asset;
|
||||
|
||||
class ProcessAllianceAssets implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
//Private variable
|
||||
private $asset;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct($a)
|
||||
{
|
||||
//
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
|
||||
$this->asset = $a;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,6 +39,40 @@ class ProcessAllianceAssets implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
/**
|
||||
* If the asset is not in the database, then let's save it to the database,
|
||||
* otherwise, we just update the old asset
|
||||
*/
|
||||
if(Asset::where(['item_id' => $this->asset->item_id])->count() == 0) {
|
||||
$as = new Asset;
|
||||
if(isset($this->asset->is_blueprint_copy)) {
|
||||
$as->is_blueprint_copy = $this->asset->is_blueprint_copy;
|
||||
}
|
||||
$as->is_singleton = $this->asset->is_singleton;
|
||||
$as->item_id = $this->asset->item_id;
|
||||
$as->location_flag = $this->asset->location_flag;
|
||||
$as->quantity = $this->asset->quantity;
|
||||
$as->type_id = $this->asset->type_id;
|
||||
$as->save();
|
||||
} else {
|
||||
//Update the previously found asset
|
||||
Asset::where([
|
||||
'item_id' => $this->asset->item_id,
|
||||
])->update([
|
||||
'is_blueprint_copy' => $this->asset->is_blueprint_copy,
|
||||
'location_flag' => $this->asset->location_flag,
|
||||
'location_type' => $this->asset->location_type,
|
||||
'quantity' => $this->asset->quantity,
|
||||
'type_id' => $this->asset->type_id,
|
||||
]);
|
||||
|
||||
if(isset($this->asset->is_singleton)) {
|
||||
Asset::where([
|
||||
'item_id' => $this->asset->item_id,
|
||||
])->update([
|
||||
'is_singleton' => $this->asset->is_singleton,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ class PurgeAllianceAssets implements ShouldQueue
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,7 +29,8 @@ class FetchAllianceStructures implements ShouldQueue
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,6 +33,9 @@ class ProcessAllianceStructures implements ShouldQueue
|
||||
*/
|
||||
public function __construct($s)
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
|
||||
//Set variables
|
||||
$this->structure = $s;
|
||||
}
|
||||
@@ -69,7 +72,7 @@ class ProcessAllianceStructures implements ShouldQueue
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Get the solar system name
|
||||
$solarName = $lookup->SolarSystemIdToName($structure->system_id);
|
||||
$solarName = $lookup->SystemIdToName($structure->system_id);
|
||||
|
||||
$s = new Structure;
|
||||
$s->structure_id = $structure->structure_id;
|
||||
|
||||
@@ -27,7 +27,8 @@ class PurgeAllianceStructures implements ShouldQueue
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,6 +41,6 @@ class PurgeAllianceStructures implements ShouldQueue
|
||||
Structure::truncate();
|
||||
Service::truncate();
|
||||
|
||||
FetchAllianceStructures::dispatch()->onQueue('default');
|
||||
FetchAllianceStructures::dispatch()->onQueue('structures');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,9 +148,10 @@ return [
|
||||
'journal',
|
||||
'mail',
|
||||
'miningtaxes',
|
||||
'structures',
|
||||
],
|
||||
'balance' => 'auto',
|
||||
'processes' => 5,
|
||||
'processes' => 10,
|
||||
'minProcesses' => 1,
|
||||
'maxProcesses' => 5,
|
||||
'tries' => 3,
|
||||
@@ -165,9 +166,10 @@ return [
|
||||
'journal',
|
||||
'mail',
|
||||
'miningtaxes',
|
||||
'structures',
|
||||
],
|
||||
'balance' => 'auto',
|
||||
'processes' => 5,
|
||||
'processes' => 10,
|
||||
'minProcesses' => 1,
|
||||
'maxProcesses' => 5,
|
||||
'tries' => 3,
|
||||
|
||||
Reference in New Issue
Block a user