removed logistics contracts and extra models as they weren't utilized.

This commit is contained in:
2019-12-01 01:36:49 -06:00
parent c400f78398
commit cd86a66b0e
5 changed files with 0 additions and 241 deletions

View File

@@ -1,122 +0,0 @@
<?php
namespace App\Console\Commands;
//Internal Library
use Illuminate\Console\Command;
use DB;
use Log;
//Job
use App\Jobs\ProcessContractsJob;
//Library
use App\Library\Esi\Esi;
use Seat\Eseye\Cache\NullCache;
use Seat\Eseye\Configuration;
use Seat\Eseye\Containers\EsiAuthentication;
use Seat\Eseye\Eseye;
use Commands\Library\CommandHelper;
use App\Library\Logistics\ContractsHelper;
//Models
use App\Models\Jobs\JobProcessContracts;
use App\Models\Esi\EsiScope;
use App\Models\Esi\EsiToken;
class GetEveContractsCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'services:GetContracts';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Get contracts from a certain corporation';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//Create the command helper container
$task = new CommandHelper('GetContracts');
//Add the entry into the jobs table saying the job is starting
$task->SetStartStatus();
//Setup the esi authentication container
$config = config('esi');
//Declare some variables
$charId = 2115439862;
$corpId = 98606886;
//Esi Scope Check
$esiHelper = new Esi();
$contractScope = $esiHelper->HaveEsiScope($charId, 'esi-contracts.read_corporation_contracts.v1');
if($contractScope == false) {
Log::critical('Scope check for esi-contracts.read_corporation_contracts.v1 failed.');
return null;
}
// Disable all caching by setting the NullCache as the
// preferred cache handler. By default, Eseye will use the
// FileCache.
$configuration = Configuration::getInstance();
$configuration->cache = NullCache::class;
//Get the refresh token from the database
$token = EsiToken::where(['character_id' => $charId])->get(['refresh_token']);
//Create the authentication container
$authentication = new EsiAuthentication([
'client_id' => $config['client_id'],
'secret' => $config['secret'],
'refresh_token' => $token[0]->refresh_token,
]);
$esi = new Eseye($authentication);
try {
$contracts = $esi->page(1)
->invoke('get', '/corporations/{corporation_id}/contracts/', [
'corporation_id' => $corpId,
]);
} catch (RequestFailedException $e) {
Log::critical("Failed to get the contracts list.");
return null;
}
$pages = $contracts->pages;
for($i = 1; $i <= $pages; $i++) {
$job = new JobProcessEveContracts;
$job->charId = $charId;
$job->corpId = $corpId;
$job->page = $i;
ProcessEveContractsJob::dispatch($job)->onQueue('default');
}
//Mark the job as finished
$task->SetStopStatus();
}
}

View File

@@ -23,7 +23,6 @@ class Kernel extends ConsoleKernel
Commands\MoonMailerCommand::class,
Commands\GetStructuresCommand::class,
Commands\GetAssetsCommand::class,
Commands\GetEveContractsCommand::class,
Commands\PurgeUsers::class,
];

View File

@@ -1,76 +0,0 @@
<?php
namespace App\Jobs;
//Internal Library
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
//App Library
use App\Library\Logistics\ContractsHelper;
//App Models
use App\Models\Jobs\JobProcessContracts;
use App\Models\Job\JobStatus;
class ProcessEveContractsJob 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;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(JobProcessContracts $jpc)
{
$this->charId = $jpc->charId;
$this->corpId = $jpc->corpId;
$this->page = $jpc->page;
//Set the connection for the job
$this->connection = 'redis';
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
//Declare the contracts helper
$cHelper = new EveContractsHelper($this->charId, $this->corpId, $this->page);
$contracts = $cHelper->GetContractsByPage();
foreach($contracts as $contract) {
$cHelper->ProcessContract($contract);
}
//After the job is completed, delete the job
$this->delete();
}
}

View File

@@ -1,19 +0,0 @@
<?php
namespace App\Models\Jobs;
use Illuminate\Database\Eloquent\Model;
class JobProcessContracts extends Model
{
//No table name is needed
//Timestamps
public $timestamps = false;
protected $fillable = [
'charId',
'corpId',
'page',
];
}

View File

@@ -1,23 +0,0 @@
<?php
namespace App\Models\Jobs;
use Illuminate\Database\Eloquent\Model;
class JobProcessWalletTransaction extends Model
{
//Timestamps
public $timestamps = false;
/**
* The attributes that are mass assignable
*
* @var array
*/
protected $fillable = [
'charId',
'division',
];
}
?>