updated several jobs. removed the task for starting and stoppinig jobs. just seems to be unnecessary data
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
namespace App\Jobs\Commands\Eve;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
namespace App\Jobs\Commands\Finances;
|
||||
|
||||
//Internal Libraries
|
||||
use Illuminate\Bus\Queueable;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Mining;
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Mining;
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Mining;
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -8,7 +8,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ProcessMiningTaxesInvoiceJob implements ShouldQueue
|
||||
class FetchMiningTaxesLedgersJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
+23
-24
@@ -1,21 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
|
||||
//App Library
|
||||
use App\Library\Structures\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobStatus;
|
||||
|
||||
class ProcessStructureJob implements ShouldQueue
|
||||
class FetchMiningTaxesObserversJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
@@ -28,6 +21,8 @@ class ProcessStructureJob implements ShouldQueue
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
@@ -36,18 +31,16 @@ class ProcessStructureJob implements ShouldQueue
|
||||
*/
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId, $corpId, $page)
|
||||
public function __construct($charId, $corpId)
|
||||
{
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->page = $page;
|
||||
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
@@ -55,24 +48,30 @@ class ProcessStructureJob implements ShouldQueue
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* The job's task is to get all of the information for a particular structure
|
||||
* and store it in the database. This task can take a few seconds because of the ESI
|
||||
* calls required to store the information. We leave this type of job up to the queue
|
||||
* in order to take the load off of the cron job.
|
||||
* The job's duty is to get all of the corporation's moon mining observers,
|
||||
* then store them in the database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$sHelper = new StructureHelper($this->charId, $this->corpId);
|
||||
|
||||
$structures = $sHelper->GetStructuresByPage($this->page);
|
||||
/**
|
||||
* Remove the current observers from the database.
|
||||
*/
|
||||
|
||||
foreach($structures as $structure) {
|
||||
$sHelper->ProcessStructure($structure);
|
||||
}
|
||||
/**
|
||||
* Create the esi call to get the current observers
|
||||
*/
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
/**
|
||||
* Add the current observers in the database
|
||||
*/
|
||||
|
||||
/**
|
||||
* Cleanup
|
||||
*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class MailMiningTaxesInvoiceJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\MiningTaxes;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class ProcessMiningTaxesPaymentsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ use Carbon\Carbon;
|
||||
use App\Library\Lookups\LookupHelper;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEvveMailJob;
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
//Models
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
|
||||
@@ -18,7 +18,7 @@ use App\Library\Lookups\LookupHelper;
|
||||
use App\Models\MoonRentals\AllianceRentalMoon;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
class UpdateMoonRentalPaidState implements ShouldQueue
|
||||
{
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Structures;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Jobs\Library\JobHelper;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Assets\AssetHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Structure\Asset;
|
||||
|
||||
class ProcessAssetsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
private $esi;
|
||||
private $currentPage;
|
||||
private $totalPages;
|
||||
private $config;
|
||||
|
||||
protected $location_array = [
|
||||
'StructureFuel',
|
||||
'FighterBay',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId, $corpId, $page)
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->currentPage = 1;
|
||||
$this->totalPages = 1;
|
||||
|
||||
$this->config = config('esi');
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* The job's task is to get all of 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()
|
||||
{
|
||||
//Declare variables
|
||||
$esiHelper = new Esi;
|
||||
$aHelper = new AssetHelper($this->charId, $this->corpId);
|
||||
|
||||
//ESI Scope Check
|
||||
$assetScope = $esiHelper->HaveEsiScope($this->config['primary'], 'esi-assets.read_corporation_assets.v1');
|
||||
|
||||
if($assetScope == false) {
|
||||
Log::critical("Scope check for esi-assets.read_corporations_assets.v1 has failed in ProcessAssetsJob");
|
||||
return null;
|
||||
}
|
||||
|
||||
//Truncate the Asset data from the table
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Create the authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
try {
|
||||
$assets = $esi->page($this->currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/assets/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get asset list in ProcessAssetsJob");
|
||||
return null;
|
||||
}
|
||||
|
||||
//Set the total number of pages
|
||||
$this->totalPages = $assets->pages;
|
||||
|
||||
//Do this while the total pages is not completed
|
||||
do {
|
||||
if($currentPage > 1) {
|
||||
try {
|
||||
$assets = $esi->page($this->currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/assets/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get asset list on page " . $this->currentPage . " in ProcessAssetsJob");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//Cycle through the assets, and attempt to store them.
|
||||
foreach($assets as $asset) {
|
||||
//if the asset is in one of the locations we want, then store
|
||||
//or update the asset
|
||||
if(in_array($asset->location_flag, $this->location_array)) {
|
||||
//Attempt to store the asset
|
||||
$aHelper->StoreNewAsset($asset);
|
||||
}
|
||||
}
|
||||
|
||||
//Increment the current page before doing the loop again
|
||||
$this->currentPage++;
|
||||
} while($this->currentPage <= $this->totalPages);
|
||||
|
||||
//Once all the data is stored and updated, purge stale data
|
||||
$aHelper->PurgeStaleData();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Commands\Structures;
|
||||
|
||||
//Internal Library
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Library\Esi\Esi;
|
||||
use Seat\Eseye\Exceptions\RequestionFailedException;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Esi\EsiScope;
|
||||
use App\Models\Esi\EsiToken;
|
||||
use App\Models\Structure\Structure;
|
||||
use App\Models\Structure\Service;
|
||||
|
||||
class ProcessStructureJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $totalPages;
|
||||
private $currentPage;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId, $corpId)
|
||||
{
|
||||
//Set the connection for the job
|
||||
$this->connection = 'redis';
|
||||
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->currentPage = 1;
|
||||
$this->totalPages = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
* The job's task is to get all of the information for a particular structure
|
||||
* and store it in the database. This task can take a few seconds because of the ESI
|
||||
* calls required to store the information. We leave this type of job up to the queue
|
||||
* in order to take the load off of the cron job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$config = config('esi');
|
||||
$sHelper = new StructureHelper($this->charId, $this->corpId);
|
||||
$structures = null;
|
||||
|
||||
//ESI Scope Check
|
||||
$esiHelper = new Esi;
|
||||
$structureScope = $esiHelper->HaveEsiScope($charId, 'esi-universe.read_structures.v1');
|
||||
$corpStructureScope = $esiHelper->HaveEsiScope($charId, 'esi-corporations.read_structures.v1');
|
||||
|
||||
//Check scopes
|
||||
if($structureScope == false || $corpStructureScope == false) {
|
||||
if($structureScope == false) {
|
||||
Log::critical("Scope check for esi-universe.read_structures.v1 has failed.");
|
||||
}
|
||||
if($corpStructureScope == false) {
|
||||
Log::critical("Scope check for esi-corporations.read_structures.v1 has failed.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Get the refresh token from the database
|
||||
$token = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Create the esi authentication container
|
||||
$esi = $esiHelper->SetupEsiAuthentication($token);
|
||||
|
||||
//Attempt to get the ESI data
|
||||
try {
|
||||
$structures = $esi->page($this->currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/structures/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch (RequestFailedException $e) {
|
||||
Log::critical("Failed to get structure list in ProcessStructureJob");
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->totalPages = $structures->pages;
|
||||
|
||||
//Truncate the structures and the structure services in order to add the latest data
|
||||
Structure::truncate();
|
||||
Service::truncate();
|
||||
|
||||
do {
|
||||
if($this->currentPage > 1) {
|
||||
try {
|
||||
$structures = $esi->page($this->currentPage)
|
||||
->invoke('get', '/corporations/{corporation_id}/structures/', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get structure list on page" . $this->currentPage . " in ProcessStructureJob.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//For each set of data, process the data
|
||||
foreach($structures as $structure) {
|
||||
$sHelper->ProcessStructure($structure);
|
||||
}
|
||||
//Increment the current page
|
||||
$this->currentPage++;
|
||||
} while($this->currentPage <= $this->totalPages);
|
||||
|
||||
//After the job is completed, delete the job
|
||||
$this->delete();
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ use App\Models\Contracts\SupplyChainBid;
|
||||
use App\Models\Contracts\SupplyChainContract;
|
||||
|
||||
//Jobs
|
||||
use App\Jobs\ProcessSendEveMailJob;
|
||||
use App\Jobs\Commands\Eve\ProcessSendEveMailJob;
|
||||
|
||||
class EndSupplyChainContractJob implements ShouldQueue
|
||||
{
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Log;
|
||||
|
||||
//App Library
|
||||
use App\Library\Structures\StructureHelper;
|
||||
use App\Jobs\Library\JobHelper;
|
||||
use Seat\Eseye\Cache\NullCache;
|
||||
use Seat\Eseye\Configuration;
|
||||
use Seat\Eseye\Containers\EsiAuthentication;
|
||||
use Seat\Eseye\Eseye;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Assets\AssetHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\Jobs\JobStatus;
|
||||
use App\Models\Stock\Asset;
|
||||
|
||||
class ProcessAssetsJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Timeout in seconds
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
public $timeout = 3600;
|
||||
|
||||
/**
|
||||
* Number of job retries
|
||||
*/
|
||||
public $tries = 3;
|
||||
|
||||
/**
|
||||
* Job Variables
|
||||
*/
|
||||
private $charId;
|
||||
private $corpId;
|
||||
private $page;
|
||||
private $esi;
|
||||
|
||||
protected $location_array = [
|
||||
'StructureFuel',
|
||||
'FighterBay',
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($charId, $corpId, $page)
|
||||
{
|
||||
$this->charId = $charId;
|
||||
$this->corpId = $corpId;
|
||||
$this->page = $page;
|
||||
|
||||
//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()
|
||||
{
|
||||
//Declare the asset helper
|
||||
$aHelper = new AssetHelper($this->charId, $this->corpId, $this->page);
|
||||
|
||||
//Get a page of assets
|
||||
$assets = $aHelper->GetAssetsByPage();
|
||||
|
||||
//Cycle through the assets, and attmept to store them.
|
||||
foreach($assets as $asset) {
|
||||
//If the asset is in one of the locations we want, then store
|
||||
//or update the asset
|
||||
if(in_array($asset->location_flag, $this->location_array)) {
|
||||
//Attempt to store the asset
|
||||
$aHelper->StoreNewAsset($asset);
|
||||
}
|
||||
}
|
||||
|
||||
//Purge Stale Data
|
||||
$aHelper->PurgeStaleData();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user