codebase
This commit is contained in:
@@ -48,9 +48,54 @@ class MiningTaxesObservers extends Command
|
||||
//Set the task as started
|
||||
$task->SetStartStatus();
|
||||
|
||||
//Declare variables
|
||||
$config = config('esi');
|
||||
$lookup = new LookupHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
//Check for the esi scope
|
||||
if(!$esiHelper->HaveEsiScope($config['primary'], 'esi-industry.read_corporation_mining.v1') || !$esiHelper->HaveEsiScope($config['corporation'], 'esi-universe.read_structures.v1')) {
|
||||
Log::critical('Esi scopes were not found for FetchMiningTaxesObserversJob.');
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the refresh token for the character
|
||||
$refreshToken = $esiHelper->GetRefreshToken($this->charId);
|
||||
//Get the esi variable
|
||||
$esi = $esiHelper->SetupEsiAuthentication($refreshToken);
|
||||
|
||||
try {
|
||||
$response = $esi->invoke('get', '/corporations/{corporation_id}/mining/observers', [
|
||||
'corporation_id' => $this->corpId,
|
||||
]);
|
||||
} catch(RequestFailedException $e) {
|
||||
Log::critical("Failed to get moon observers in FetchMiningTaxesObservers");
|
||||
Log::critical($e);
|
||||
}
|
||||
|
||||
$resp = json_decode($response, false);
|
||||
|
||||
dd($resp);
|
||||
|
||||
//Run through the mining observers, and add them to the database
|
||||
foreach($resp as $observer) {
|
||||
|
||||
Observer::updateOrInsert([
|
||||
'observer_id' => $observer->observer_id,
|
||||
], [
|
||||
'observer_id' => $observer->observer_id,
|
||||
'observer_type' => $observer->observer_type,
|
||||
'last_updated' => $observer->last_updated,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup stale data that hasn't been updated in at least 1 week.
|
||||
*/
|
||||
$date = Carbon::now()->subDay(7);
|
||||
Observer::where('updated_at', '<', $date)->delete();
|
||||
|
||||
|
||||
FetchMiningTaxesObserversJob::dispatch($config['primary'], $config['corporation'])->onQueue('miningtaxes');
|
||||
|
||||
$task->SetStopStatus();
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ use Log;
|
||||
use Seat\Eseye\Exceptions\RequestFailedException;
|
||||
use App\Library\Esi\Esi;
|
||||
use App\Library\Helpers\LookupHelper;
|
||||
use App\Library\Helpers\StructureHelper;
|
||||
|
||||
//App Models
|
||||
use App\Models\MiningTax\Observer;
|
||||
@@ -67,7 +66,6 @@ class FetchMiningTaxesObserversJob implements ShouldQueue
|
||||
public function handle()
|
||||
{
|
||||
//Declare variables
|
||||
$sHelper = new StructureHelper($this->charId, $this->corpId);
|
||||
$lookup = new LookupHelper;
|
||||
$esiHelper = new Esi;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user